exceptions.py 1.7 KB

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