|
@@ -19,6 +19,7 @@ from celery._state import (
|
|
|
get_current_app as current_app,
|
|
|
get_current_task as current_task,
|
|
|
_get_active_apps,
|
|
|
+ _task_stack,
|
|
|
)
|
|
|
from celery.utils import gen_task_name
|
|
|
|
|
@@ -27,7 +28,8 @@ from .base import Celery, AppPickler
|
|
|
|
|
|
__all__ = ['Celery', 'AppPickler', 'default_app', 'app_or_default',
|
|
|
'bugreport', 'enable_trace', 'disable_trace', 'shared_task',
|
|
|
- 'set_default_app', 'current_app', 'current_task']
|
|
|
+ 'set_default_app', 'current_app', 'current_task',
|
|
|
+ 'push_current_task', 'pop_current_task']
|
|
|
|
|
|
#: Proxy always returning the app set as default.
|
|
|
default_app = Proxy(lambda: _state.default_app)
|
|
@@ -45,6 +47,17 @@ app_or_default = None
|
|
|
default_loader = os.environ.get('CELERY_LOADER') or 'default' # XXX
|
|
|
|
|
|
|
|
|
+#: Function used to push a task to the thread local stack
|
|
|
+#: keeping track of the currently executing task.
|
|
|
+#: You must remember to pop the task after.
|
|
|
+push_current_task = _task_stack.push
|
|
|
+
|
|
|
+#: Function used to pop a task from the thread local stack
|
|
|
+#: keeping track of the currently executing task.
|
|
|
+pop_current_task = _task_stack.pop
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
def bugreport(app=None):
|
|
|
return (app or current_app()).bugreport()
|
|
|
|