exceptions.py 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. # -*- coding: utf-8 -*-
  2. """
  3. celery.exceptions
  4. ~~~~~~~~~~~~~~~~~
  5. This module contains all exceptions used by the Celery API.
  6. """
  7. from __future__ import absolute_import
  8. from billiard.exceptions import ( # noqa
  9. SoftTimeLimitExceeded, TimeLimitExceeded, WorkerLostError,
  10. )
  11. UNREGISTERED_FMT = """\
  12. Task of kind %s is not registered, please make sure it's imported.\
  13. """
  14. class SecurityError(Exception):
  15. """Security related exceptions.
  16. Handle with care.
  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 ImproperlyConfigured(ImportError):
  23. """Celery is somehow improperly configured."""
  24. class NotRegistered(KeyError):
  25. """The task is not registered."""
  26. def __repr__(self):
  27. return UNREGISTERED_FMT % str(self)
  28. class AlreadyRegistered(Exception):
  29. """The task is already registered."""
  30. class TimeoutError(Exception):
  31. """The operation timed out."""
  32. class MaxRetriesExceededError(Exception):
  33. """The tasks max restart limit has been exceeded."""
  34. class RetryTaskError(Exception):
  35. """The task is to be retried later."""
  36. def __init__(self, message, exc, *args, **kwargs):
  37. self.exc = exc
  38. Exception.__init__(self, message, exc, *args, **kwargs)
  39. class TaskRevokedError(Exception):
  40. """The task has been revoked, so no result available."""
  41. class NotConfigured(UserWarning):
  42. """Celery has not been configured, as no config module has been found."""
  43. class AlwaysEagerIgnored(UserWarning):
  44. """send_task ignores CELERY_ALWAYS_EAGER option"""
  45. class InvalidTaskError(Exception):
  46. """The task has invalid data or is not properly constructed."""
  47. class CPendingDeprecationWarning(PendingDeprecationWarning):
  48. pass
  49. class CDeprecationWarning(DeprecationWarning):
  50. pass
  51. class IncompleteStream(Exception):
  52. """Found the end of a stream of data, but the data is not yet complete."""