MCPcopy
hub / github.com/celery/celery / retry

Method retry

celery/app/task.py:680–791  ·  celery/app/task.py::Task.retry

Retry the task, adding it to the back of the queue. Example: >>> from imaginary_twitter_lib import Twitter >>> from proj.celery import app >>> @app.task(bind=True) ... def tweet(self, auth, message): ... twitter = Twitter(oaut

(self, args=None, kwargs=None, exc=None, throw=True,
              eta=None, countdown=None, max_retries=None, **options)

Source from the content-addressed store, hash-verified

678 subtask_from_request = signature_from_request class="cm"># XXX compat
679
680 def retry(self, args=None, kwargs=None, exc=None, throw=True,
681 eta=None, countdown=None, max_retries=None, **options):
682 class="st">"""Retry the task, adding it to the back of the queue.
683
684 Example:
685 >>> from imaginary_twitter_lib import Twitter
686 >>> from proj.celery import app
687
688 >>> @app.task(bind=True)
689 ... def tweet(self, auth, message):
690 ... twitter = Twitter(oauth=auth)
691 ... try:
692 ... twitter.post_status_update(message)
693 ... except twitter.FailWhale as exc:
694 ... class="cm"># Retry in 5 minutes.
695 ... raise self.retry(countdown=60 * 5, exc=exc)
696
697 Note:
698 Although the task will never return above as `retry` raises an
699 exception to notify the worker, we use `raise` in front of the
700 retry to convey that the rest of the block won&class="cm">#x27;t be executed.
701
702 Arguments:
703 args (Tuple): Positional arguments to retry with.
704 kwargs (Dict): Keyword arguments to retry with.
705 exc (Exception): Custom exception to report when the max retry
706 limit has been exceeded (default:
707 :exc:`~@MaxRetriesExceededError`).
708
709 If this argument is set and retry is called while
710 an exception was raised (``sys.exc_info()`` is set)
711 it will attempt to re-raise the current exception.
712
713 If no exception was raised it will raise the ``exc``
714 argument provided.
715 countdown (float): Time in seconds to delay the retry for.
716 eta (~datetime.datetime): Explicit time and date to run the
717 retry at.
718 max_retries (int): If set, overrides the default retry limit for
719 this execution. Changes to this parameter don&class="cm">#x27;t propagate to
720 subsequent task retry attempts. A value of :const:`None`,
721 means class="st">"use the default", so if you want infinite retries you&class="cm">#x27;d
722 have to set the :attr:`max_retries` attribute of the task to
723 :const:`None` first.
724 time_limit (int): If set, overrides the default time limit.
725 soft_time_limit (int): If set, overrides the default soft
726 time limit.
727 throw (bool): If this is :const:`False`, don&class="cm">#x27;t raise the
728 :exc:`~@Retry` exception, that tells the worker to mark
729 the task as being retried. Note that this means the task
730 will be marked as failed if the task raises an exception,
731 or successful if it returns after the retry call.
732 **options (Any): Extra options to pass on to :meth:`apply_async`.
733
734 Raises:
735
736 celery.exceptions.Retry:
737 To tell the worker that the task has been re-sent for retry.

Callers 15

retryFunction · 0.80
retry_unpickleableFunction · 0.80
retry_onceFunction · 0.80
retry_once_priorityFunction · 0.80
retry_once_headersFunction · 0.80
task_retry_then_failMethod · 0.80
retry_taskMethod · 0.80
retry_taskMethod · 0.80
retry_task_noargsMethod · 0.80

Calls 6

raise_with_contextFunction · 0.90
RetryClass · 0.90
RejectClass · 0.90
formatMethod · 0.45
apply_asyncMethod · 0.45