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.
()
| 120 | |
| 121 | |
| 122 | def 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 | |
| 136 | def task_callable_qualname(task): |
no test coverage detected