exceptions.py 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. UNREGISTERED_FMT = """\
  2. Task of kind %s is not registered, please make sure it's imported.\
  3. """
  4. class SystemTerminate(SystemExit):
  5. """Signals that the worker should terminate."""
  6. class QueueNotFound(KeyError):
  7. """Task routed to a queue not in CELERY_QUEUES."""
  8. class TimeLimitExceeded(Exception):
  9. """The time limit has been exceeded and the job has been terminated."""
  10. class SoftTimeLimitExceeded(Exception):
  11. """The soft time limit has been exceeded. This exception is raised
  12. to give the task a chance to clean up."""
  13. class WorkerLostError(Exception):
  14. """The worker processing a job has exited prematurely."""
  15. class ImproperlyConfigured(Exception):
  16. """Celery is somehow improperly configured."""
  17. class NotRegistered(KeyError):
  18. """The task is not registered."""
  19. def __repr__(self):
  20. return UNREGISTERED_FMT % str(self)
  21. class AlreadyRegistered(Exception):
  22. """The task is already registered."""
  23. class TimeoutError(Exception):
  24. """The operation timed out."""
  25. class MaxRetriesExceededError(Exception):
  26. """The tasks max restart limit has been exceeded."""
  27. class RetryTaskError(Exception):
  28. """The task is to be retried later."""
  29. def __init__(self, message, exc, *args, **kwargs):
  30. self.exc = exc
  31. Exception.__init__(self, message, exc, *args, **kwargs)
  32. class TaskRevokedError(Exception):
  33. """The task has been revoked, so no result available."""
  34. class NotConfigured(UserWarning):
  35. """Celery has not been configured, as no config module has been found."""