a guest Jul 18th, 2019 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     def retry(self, args=None, kwargs=None, exc=None, throw=True,
  2.               eta=None, countdown=None, max_retries=None, **options):
  3.         """Retry the task, adding it to the back of the queue.
  5.         Example:
  6.             >>> from imaginary_twitter_lib import Twitter
  7.             >>> from proj.celery import app
  9.             >>> @app.task(bind=True)
  10.             ... def tweet(self, auth, message):
  11.             ...     twitter = Twitter(oauth=auth)
  12.             ...     try:
  13.             ...         twitter.post_status_update(message)
  14.             ...     except twitter.FailWhale as exc:
  15.             ...         # Retry in 5 minutes.
  16.             ...         raise self.retry(countdown=60 * 5, exc=exc)
  18.         Note:
  19.             Although the task will never return above as `retry` raises an
  20.             exception to notify the worker, we use `raise` in front of the
  21.             retry to convey that the rest of the block won't be executed.
  23.         Arguments:
  24.             args (Tuple): Positional arguments to retry with.
  25.             kwargs (Dict): Keyword arguments to retry with.
  26.             exc (Exception): Custom exception to report when the max retry
  27.                 limit has been exceeded (default:
  28.                 :exc:`~@MaxRetriesExceededError`).
  30.                 If this argument is set and retry is called while
  31.                 an exception was raised (``sys.exc_info()`` is set)
  32.                 it will attempt to re-raise the current exception.
  34.                 If no exception was raised it will raise the ``exc``
  35.                 argument provided.
  36.             countdown (float): Time in seconds to delay the retry for.
  37.             eta (~datetime.datetime): Explicit time and date to run the
  38.                 retry at.
  39.             max_retries (int): If set, overrides the default retry limit for
  40.                 this execution.  Changes to this parameter don't propagate to
  41.                 subsequent task retry attempts.  A value of :const:`None`,
  42.                 means "use the default", so if you want infinite retries you'd
  43.                 have to set the :attr:`max_retries` attribute of the task to
  44.                 :const:`None` first.
  45.             time_limit (int): If set, overrides the default time limit.
  46.             soft_time_limit (int): If set, overrides the default soft
  47.                 time limit.
  48.             throw (bool): If this is :const:`False`, don't raise the
  49.                 :exc:`~@Retry` exception, that tells the worker to mark
  50.                 the task as being retried.  Note that this means the task
  51.                 will be marked as failed if the task raises an exception,
  52.                 or successful if it returns after the retry call.
  53.             **options (Any): Extra options to pass on to :meth:`apply_async`.
  55.         Raises:
  57.             celery.exceptions.Retry:
  58.                 To tell the worker that the task has been re-sent for retry.
  59.                 This always happens, unless the `throw` keyword argument
  60.                 has been explicitly set to :const:`False`, and is considered
  61.                 normal operation.
  62.         """
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand