MCPcopy Create free account
hub / github.com/celery/celery / caller_stacklevel

Function caller_stacklevel

celery/app/base.py:122–133  ·  view source on GitHub ↗

Depth of the first frame outside Celery, for :func:`warnings.warn`. A task can be registered straight from the decorator or later, when a :class:`~celery.local.PromiseProxy` is first evaluated, and those two paths sit at different depths -- so the level is found rather than assumed.

()

Source from the content-addressed store, hash-verified

120
121
122def caller_stacklevel():
123 """Depth of the first frame outside Celery, for :func:`warnings.warn`.
124
125 A task can be registered straight from the decorator or later, when a
126 :class:`~celery.local.PromiseProxy` is first evaluated, and those two
127 paths sit at different depths -- so the level is found rather than
128 assumed. Only reached when a warning is actually emitted.
129 """
130 frame, level = sys._getframe(1), 1
131 while frame is not None and frame_is_celery(frame):
132 frame, level = frame.f_back, level + 1
133 return level
134
135
136def task_callable_qualname(task):

Callers 1

Calls 1

frame_is_celeryFunction · 0.85

Tested by

no test coverage detected