def cry(out=None, sepchr='=', seplen=49): # pragma: no cover """Return stacktrace of all active threads, taken from https://gist.github.com/737056.""" import threading out = StringIO() if out is None else out P = partial(print, file=out) # get a map of threads by their ID so we can print their names # during the traceback dump tmap = dict((t.ident, t) for t in threading.enumerate()) sep = sepchr * seplen for tid, frame in items(sys._current_frames()): thread = tmap.get(tid) if not thread: # skip old junk (left-overs from a fork) continue P('{0.name}'.format(thread)) P(sep) traceback.print_stack(frame, file=out) P(sep) P('LOCAL VARIABLES') P(sep) pprint(frame.f_locals, stream=out) P('\n') return out.getvalue()
def cry(): # pragma: no cover """Return stacktrace of all active threads. From https://gist.github.com/737056 """ import threading tmap = {} main_thread = None # get a map of threads by their ID so we can print their names # during the traceback dump for t in threading.enumerate(): if getattr(t, 'ident', None): tmap[t.ident] = t else: main_thread = t out = StringIO() P = partial(print, file=out) sep = '=' * 49 for tid, frame in items(sys._current_frames()): thread = tmap.get(tid, main_thread) if not thread: # skip old junk (left-overs from a fork) continue P('{0.name}'.format(thread)) P(sep) traceback.print_stack(frame, file=out) P(sep) P('LOCAL VARIABLES') P(sep) pprint(frame.f_locals, stream=out) P('\n') return out.getvalue()
def cry(out=None, sepchr='=', seplen=49): # pragma: no cover """Return stacktrace of all active threads. From https://gist.github.com/737056 """ import threading out = StringIO() if out is None else out P = partial(print, file=out) # get a map of threads by their ID so we can print their names # during the traceback dump tmap = dict((t.ident, t) for t in threading.enumerate()) sep = sepchr * seplen for tid, frame in items(sys._current_frames()): thread = tmap.get(tid) if not thread: # skip old junk (left-overs from a fork) continue P('{0.name}'.format(thread)) P(sep) traceback.print_stack(frame, file=out) P(sep) P('LOCAL VARIABLES') P(sep) pprint(frame.f_locals, stream=out) P('\n') return out.getvalue()
def memdump(state, samples=10, **kwargs): # pragma: no cover from celery.utils.debug import memdump out = StringIO() memdump(file=out) return out.getvalue()
def memdump(panel, samples=10, **kwargs): from celery.utils.debug import memdump out = StringIO() memdump(file=out) return out.getvalue()