Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Adds Celery.current_task

  • Loading branch information...
commit 313b71fd68befdb3ef42640d532e2c1ecda1a023 1 parent e4dbf10
@ask authored
Showing with 9 additions and 1 deletion.
  1. +5 −1 celery/app/base.py
  2. +4 −0 docs/reference/celery.rst
View
6 celery/app/base.py
@@ -27,7 +27,7 @@
from celery.exceptions import AlwaysEagerIgnored
from celery.loaders import get_loader_cls
from celery.local import PromiseProxy, maybe_evaluate
-from celery.state import _tls, get_current_app
+from celery.state import _task_stack, _tls, get_current_app
from celery.utils.functional import first
from celery.utils.imports import instantiate, symbol_by_name
@@ -391,6 +391,10 @@ def pool(self):
limit=self.conf.BROKER_POOL_LIMIT)
return self._pool
+ @property
+ def current_task(self):
+ return _task_stack.top
+
@cached_property
def amqp(self):
"""Sending/receiving messages. See :class:`~celery.app.amqp.AMQP`."""
View
4 docs/reference/celery.rst
@@ -36,6 +36,10 @@ Application
Current configuration.
+ .. attribute:: current_task
+
+ The instance of the task that is being executed, or :const:`None`.
+
.. attribute:: amqp
AMQP related functionality: :class:`~@amqp`.
Please sign in to comment.
Something went wrong with that request. Please try again.