def dump_traceback(file=sys.stderr, all_threads=True):
 current_thread = threading.current_thread()
 if all_threads:
  threads = threading.enumerate()
 else:
  threads = [current_thread]
 for thread in threads:
  if (thread == current_thread):
   name = 'Current thread'
  else:
   name = 'Thread'
  print >>file, ('%s %s %s (most recent call last):' % (name, thread.name, thread.ident))
  frame = sys._current_frames()[thread.ident]
  traceback.print_stack(frame, file=file)
  print >>file

def dump_traceback ( file = sys . stderr , all_threads = True ) : current_thread = threading . current_thread ( ) if all_threads : threads = threading . enumerate ( ) else : threads = [ current_thread ] for thread in threads : if ( thread == current_thread ) : name = 'Current thread' else : name = 'Thread' print >> file , ( '%s %s %s (most recent call last):' % ( name , thread . name , thread . ident ) ) frame = sys . _current_frames ( ) [ thread . ident ] traceback . print_stack ( frame , file = file ) print >> file
print a thread stacktrace .