def coroutine_traceback(typ, value, tb):
 all_frames = traceback.extract_tb(tb)
 useful_frames = []
 for frame in all_frames:
  if ((frame[0] == '<string>') and (frame[2] == 'raise_exc_info')):
   continue
  elif (frame[0].endswith('tornado/gen.py') and (frame[2] in {'run', 'wrapper'})):
   continue
  elif (frame[0].endswith('tornado/concurrent.py') and (frame[2] == 'result')):
   continue
  useful_frames.append(frame)
 tb_list = ['Traceback (most recent call last):\n']
 tb_list.extend(traceback.format_list(useful_frames))
 tb_list.extend(traceback.format_exception_only(typ, value))
 return tb_list

def coroutine_traceback ( typ , value , tb ) : all_frames = traceback . extract_tb ( tb ) useful_frames = [ ] for frame in all_frames : if ( ( frame [ 0 ] == '<string>' ) and ( frame [ 2 ] == 'raise_exc_info' ) ) : continue elif ( frame [ 0 ] . endswith ( 'tornado/gen.py' ) and ( frame [ 2 ] in { 'run' , 'wrapper' } ) ) : continue elif ( frame [ 0 ] . endswith ( 'tornado/concurrent.py' ) and ( frame [ 2 ] == 'result' ) ) : continue useful_frames . append ( frame ) tb_list = [ 'Traceback (most recent call last):\n' ] tb_list . extend ( traceback . format_list ( useful_frames ) ) tb_list . extend ( traceback . format_exception_only ( typ , value ) ) return tb_list
scrub coroutine frames from a traceback coroutine tracebacks have a bunch of identical uninformative frames at each yield point .