exceptions.py 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. # -*- coding: utf-8 -*-
  2. """
  3. celery.exceptions
  4. ~~~~~~~~~~~~~~~~~
  5. This module contains Celery-specific exceptions.
  6. :copyright: (c) 2009 - 2012 by Ask Solem.
  7. :license: BSD, see LICENSE for more details.
  8. """
  9. from __future__ import absolute_import
  10. from billiard.exceptions import ( # noqa
  11. SoftTimeLimitExceeded, TimeLimitExceeded, WorkerLostError,
  12. )
  13. UNREGISTERED_FMT = """\
  14. Task of kind %s is not registered, please make sure it's imported.\
  15. """
  16. class SecurityError(Exception):
  17. """Security related exceptions.
  18. Handle with care.
  19. """
  20. class SystemTerminate(SystemExit):
  21. """Signals that the worker should terminate."""
  22. class QueueNotFound(KeyError):
  23. """Task routed to a queue not in CELERY_QUEUES."""
  24. class ImproperlyConfigured(ImportError):
  25. """Celery is somehow improperly configured."""
  26. class NotRegistered(KeyError):
  27. """The task is not registered."""
  28. def __repr__(self):
  29. return UNREGISTERED_FMT % str(self)
  30. class AlreadyRegistered(Exception):
  31. """The task is already registered."""
  32. class TimeoutError(Exception):
  33. """The operation timed out."""
  34. class MaxRetriesExceededError(Exception):
  35. """The tasks max restart limit has been exceeded."""
  36. class RetryTaskError(Exception):
  37. """The task is to be retried later."""
  38. def __init__(self, message, exc, *args, **kwargs):
  39. self.exc = exc
  40. Exception.__init__(self, message, exc, *args, **kwargs)
  41. class TaskRevokedError(Exception):
  42. """The task has been revoked, so no result available."""
  43. class NotConfigured(UserWarning):
  44. """Celery has not been configured, as no config module has been found."""
  45. class AlwaysEagerIgnored(UserWarning):
  46. """send_task ignores CELERY_ALWAYS_EAGER option"""
  47. class InvalidTaskError(Exception):
  48. """The task has invalid data or is not properly constructed."""
  49. class CPendingDeprecationWarning(PendingDeprecationWarning):
  50. pass
  51. class CDeprecationWarning(DeprecationWarning):
  52. pass
  53. class IncompleteStream(Exception):
  54. """Found the end of a stream of data, but the data is not yet complete."""