|
@@ -321,6 +321,9 @@ class Task(object):
|
|
|
_task_stack.push(self)
|
|
|
self.push_request()
|
|
|
try:
|
|
|
+ # add self if this is a bound task
|
|
|
+ if self.__self__ is not None:
|
|
|
+ return self.run(self.__self__, *args, **kwargs)
|
|
|
return self.run(*args, **kwargs)
|
|
|
finally:
|
|
|
self.pop_request()
|
|
@@ -397,28 +400,20 @@ class Task(object):
|
|
|
:keyword retry_policy: Override the retry policy used. See the
|
|
|
:setting:`CELERY_TASK_PUBLISH_RETRY` setting.
|
|
|
|
|
|
- :keyword routing_key: The routing key used to route the task to a
|
|
|
- worker server. Defaults to the
|
|
|
- :attr:`routing_key` attribute.
|
|
|
+ :keyword routing_key: Custom routing key used to route the task to a
|
|
|
+ worker server. If in combination with a
|
|
|
+ ``queue`` argument only used to specify custom
|
|
|
+ routing keys to topic exchanges.
|
|
|
|
|
|
- :keyword exchange: The named exchange to send the task to.
|
|
|
- Defaults to the :attr:`exchange` attribute.
|
|
|
+ :keyword queue: The queue to route the task to. This must be a key
|
|
|
+ present in :setting:`CELERY_QUEUES`, or
|
|
|
+ :setting:`CELERY_CREATE_MISSING_QUEUES` must be
|
|
|
+ enabled. See :ref:`guide-routing` for more
|
|
|
+ information.
|
|
|
|
|
|
- :keyword exchange_type: The exchange type to initialize the exchange
|
|
|
- if not already declared. Defaults to the
|
|
|
- :attr:`exchange_type` attribute.
|
|
|
-
|
|
|
- :keyword immediate: Request immediate delivery. Will raise an
|
|
|
- exception if the task cannot be routed to a worker
|
|
|
- immediately. (Do not confuse this parameter with
|
|
|
- the `countdown` and `eta` settings, as they are
|
|
|
- unrelated). Defaults to the :attr:`immediate`
|
|
|
- attribute.
|
|
|
-
|
|
|
- :keyword mandatory: Mandatory routing. Raises an exception if
|
|
|
- there's no running workers able to take on this
|
|
|
- task. Defaults to the :attr:`mandatory`
|
|
|
- attribute.
|
|
|
+ :keyword exchange: Named custom exchange to send the task to.
|
|
|
+ Usually not used in combination with the ``queue``
|
|
|
+ argument.
|
|
|
|
|
|
:keyword priority: The task priority, a number between 0 and 9.
|
|
|
Defaults to the :attr:`priority` attribute.
|
|
@@ -448,6 +443,9 @@ class Task(object):
|
|
|
attribute.
|
|
|
:keyword publisher: Deprecated alias to ``producer``.
|
|
|
|
|
|
+ Also supports all keyword arguments supported by
|
|
|
+ :meth:`kombu.messaging.Producer.publish`.
|
|
|
+
|
|
|
.. note::
|
|
|
If the :setting:`CELERY_ALWAYS_EAGER` setting is set, it will
|
|
|
be replaced by a local :func:`apply` call instead.
|
|
@@ -596,7 +594,10 @@ class Task(object):
|
|
|
from celery.task.trace import eager_trace_task
|
|
|
|
|
|
app = self._get_app()
|
|
|
- args = args or []
|
|
|
+ args = args or ()
|
|
|
+ # add 'self' if this is a bound method.
|
|
|
+ if self.__self__ is not None:
|
|
|
+ args = (self.__self__, ) + tuple(args)
|
|
|
kwargs = kwargs or {}
|
|
|
task_id = options.get('task_id') or uuid()
|
|
|
retries = options.get('retries', 0)
|