/celery/exceptions.py

https://github.com/catalanojuan/celery · Python · 92 lines · 34 code · 36 blank · 22 comment · 0 complexity · 4eb5b13ad6ed51440ffaec9f2dd17bd0 MD5 · raw file

  1. """
  2. celery.exceptions
  3. =================
  4. This module contains Celery-specific exceptions.
  5. """
  6. from __future__ import absolute_import
  7. __all__ = ["SystemTerminate", "QueueNotFound",
  8. "TimeLimitExceeded", "SoftTimeLimitExceeded",
  9. "WorkerLostError", "ImproperlyConfigured",
  10. "NotRegistered", "AlreadyRegistered",
  11. "TimeoutError", "MaxRetriesExceededError",
  12. "RetryTaskError", "TaskRevokedError",
  13. "NotConfigured", "CPendingDeprecationWarning",
  14. "CDeprecationWarning"]
  15. UNREGISTERED_FMT = """\
  16. Task of kind %s is not registered, please make sure it's imported.\
  17. """
  18. class SystemTerminate(SystemExit):
  19. """Signals that the worker should terminate."""
  20. class QueueNotFound(KeyError):
  21. """Task routed to a queue not in CELERY_QUEUES."""
  22. class TimeLimitExceeded(Exception):
  23. """The time limit has been exceeded and the job has been terminated."""
  24. class SoftTimeLimitExceeded(Exception):
  25. """The soft time limit has been exceeded. This exception is raised
  26. to give the task a chance to clean up."""
  27. class WorkerLostError(Exception):
  28. """The worker processing a job has exited prematurely."""
  29. class ImproperlyConfigured(Exception):
  30. """Celery is somehow improperly configured."""
  31. class NotRegistered(KeyError):
  32. """The task is not registered."""
  33. def __repr__(self):
  34. return UNREGISTERED_FMT % str(self)
  35. class AlreadyRegistered(Exception):
  36. """The task is already registered."""
  37. class TimeoutError(Exception):
  38. """The operation timed out."""
  39. class MaxRetriesExceededError(Exception):
  40. """The tasks max restart limit has been exceeded."""
  41. class RetryTaskError(Exception):
  42. """The task is to be retried later."""
  43. def __init__(self, message, exc, *args, **kwargs):
  44. self.exc = exc
  45. Exception.__init__(self, message, exc, *args, **kwargs)
  46. class TaskRevokedError(Exception):
  47. """The task has been revoked, so no result available."""
  48. class NotConfigured(UserWarning):
  49. """Celery has not been configured, as no config module has been found."""
  50. class CPendingDeprecationWarning(PendingDeprecationWarning):
  51. pass
  52. class CDeprecationWarning(DeprecationWarning):
  53. pass