exceptions.py 1.7 KB

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