exceptions.py 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. """
  2. Common Exceptions
  3. """
  4. from billiard.pool import SoftTimeLimitExceeded as _SoftTimeLimitExceeded
  5. UNREGISTERED_FMT = """
  6. Task of kind %s is not registered, please make sure it's imported.
  7. """.strip()
  8. class RouteNotFound(KeyError):
  9. """Task routed to a queue not in the routing table (CELERY_QUEUES)."""
  10. class SoftTimeLimitExceeded(_SoftTimeLimitExceeded):
  11. """The soft time limit has been exceeded. This exception is raised
  12. to give the task a chance to clean up."""
  13. pass
  14. class ImproperlyConfigured(Exception):
  15. """Celery is somehow improperly configured."""
  16. pass
  17. class NotRegistered(KeyError):
  18. """The task is not registered."""
  19. def __init__(self, message, *args, **kwargs):
  20. message = UNREGISTERED_FMT % str(message)
  21. KeyError.__init__(self, message, *args, **kwargs)
  22. class AlreadyRegistered(Exception):
  23. """The task is already registered."""
  24. pass
  25. class TimeoutError(Exception):
  26. """The operation timed out."""
  27. pass
  28. class MaxRetriesExceededError(Exception):
  29. """The tasks max restart limit has been exceeded."""
  30. pass
  31. class RetryTaskError(Exception):
  32. """The task is to be retried later."""
  33. def __init__(self, message, exc, *args, **kwargs):
  34. self.exc = exc
  35. Exception.__init__(self, message, exc, *args, **kwargs)
  36. class TaskRevokedError(Exception):
  37. """The task has been revoked, so no result available."""
  38. pass