MCPcopy
hub / github.com/celery/celery / cry

Function cry

celery/utils/debug.py:164–193  ·  view source on GitHub ↗

Return stack-trace of all active threads. See Also: Taken from https://gist.github.com/737056.

(out=None, sepchr='=', seplen=49)

Source from the content-addressed store, hash-verified

162
163
164def cry(out=None, sepchr='=', seplen=49): # pragma: no cover
165 """Return stack-trace of all active threads.
166
167 See Also:
168 Taken from https://gist.github.com/737056.
169 """
170 import threading
171
172 out = WhateverIO() if out is None else out
173 P = partial(print, file=out)
174
175 # get a map of threads by their ID so we can print their names
176 # during the traceback dump
177 tmap = {t.ident: t for t in threading.enumerate()}
178
179 sep = sepchr * seplen
180 for tid, frame in sys._current_frames().items():
181 thread = tmap.get(tid)
182 if not thread:
183 # skip old junk (left-overs from a fork)
184 continue
185 P(f'{thread.name}')
186 P(sep)
187 traceback.print_stack(frame, file=out)
188 P(sep)
189 P('LOCAL VARIABLES')
190 P(sep)
191 pprint(frame.f_locals, stream=out)
192 P('\n')
193 return out.getvalue()

Callers 1

cry_handlerFunction · 0.90

Calls 3

WhateverIOClass · 0.90
itemsMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected