exceptions.py 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. # -*- coding: utf-8 -*-
  2. """
  3. celery.exceptions
  4. ~~~~~~~~~~~~~~~~~
  5. This module contains Celery-specific exceptions.
  6. :copyright: (c) 2009 - 2011 by Ask Solem.
  7. :license: BSD, see LICENSE for more details.
  8. """
  9. from __future__ import absolute_import
  10. UNREGISTERED_FMT = """\
  11. Task of kind %s is not registered, please make sure it's imported.\
  12. """
  13. class SystemTerminate(SystemExit):
  14. """Signals that the worker should terminate."""
  15. class QueueNotFound(KeyError):
  16. """Task routed to a queue not in CELERY_QUEUES."""
  17. class TimeLimitExceeded(Exception):
  18. """The time limit has been exceeded and the job has been terminated."""
  19. class SoftTimeLimitExceeded(Exception):
  20. """The soft time limit has been exceeded. This exception is raised
  21. to give the task a chance to clean up."""
  22. class WorkerLostError(Exception):
  23. """The worker processing a job has exited prematurely."""
  24. class ImproperlyConfigured(Exception):
  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 CPendingDeprecationWarning(PendingDeprecationWarning):
  46. pass
  47. class CDeprecationWarning(DeprecationWarning):
  48. pass