/usr/lib/python3/dist-packages/celery/exceptions.py is in python3-celery 4.1.0-2ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 | # -*- coding: utf-8 -*-
"""Celery error types.
Error Hierarchy
===============
- :exc:`Exception`
- :exc:`celery.exceptions.CeleryError`
- :exc:`~celery.exceptions.ImproperlyConfigured`
- :exc:`~celery.exceptions.SecurityError`
- :exc:`~celery.exceptions.TaskPredicate`
- :exc:`~celery.exceptions.Ignore`
- :exc:`~celery.exceptions.Reject`
- :exc:`~celery.exceptions.Retry`
- :exc:`~celery.exceptions.TaskError`
- :exc:`~celery.exceptions.QueueNotFound`
- :exc:`~celery.exceptions.IncompleteStream`
- :exc:`~celery.exceptions.NotRegistered`
- :exc:`~celery.exceptions.AlreadyRegistered`
- :exc:`~celery.exceptions.TimeoutError`
- :exc:`~celery.exceptions.MaxRetriesExceededError`
- :exc:`~celery.exceptions.TaskRevokedError`
- :exc:`~celery.exceptions.InvalidTaskError`
- :exc:`~celery.exceptions.ChordError`
- :class:`kombu.exceptions.KombuError`
- :exc:`~celery.exceptions.OperationalError`
Raised when a transport connection error occurs while
sending a message (be it a task, remote control command error).
.. note::
This exception does not inherit from
:exc:`~celery.exceptions.CeleryError`.
- **billiard errors** (prefork pool)
- :exc:`~celery.exceptions.SoftTimeLimitExceeded`
- :exc:`~celery.exceptions.TimeLimitExceeded`
- :exc:`~celery.exceptions.WorkerLostError`
- :exc:`~celery.exceptions.Terminated`
- :class:`UserWarning`
- :class:`~celery.exceptions.CeleryWarning`
- :class:`~celery.exceptions.AlwaysEagerIgnored`
- :class:`~celery.exceptions.DuplicateNodenameWarning`
- :class:`~celery.exceptions.FixupWarning`
- :class:`~celery.exceptions.NotConfigured`
- :exc:`BaseException`
- :exc:`SystemExit`
- :exc:`~celery.exceptions.WorkerTerminate`
- :exc:`~celery.exceptions.WorkerShutdown`
"""
from __future__ import absolute_import, unicode_literals
import numbers
from .five import python_2_unicode_compatible, string_t
from billiard.exceptions import (
SoftTimeLimitExceeded, TimeLimitExceeded, WorkerLostError, Terminated,
)
from kombu.exceptions import OperationalError
__all__ = [
# Warnings
'CeleryWarning',
'AlwaysEagerIgnored', 'DuplicateNodenameWarning',
'FixupWarning', 'NotConfigured',
# Core errors
'CeleryError',
'ImproperlyConfigured', 'SecurityError',
# Kombu (messaging) errors.
'OperationalError',
# Task semi-predicates
'TaskPredicate', 'Ignore', 'Reject', 'Retry',
# Task related errors.
'TaskError', 'QueueNotFound', 'IncompleteStream',
'NotRegistered', 'AlreadyRegistered', 'TimeoutError',
'MaxRetriesExceededError', 'TaskRevokedError',
'InvalidTaskError', 'ChordError',
# Billiard task errors.
'SoftTimeLimitExceeded', 'TimeLimitExceeded',
'WorkerLostError', 'Terminated',
# Deprecation warnings (forcing Python to emit them).
'CPendingDeprecationWarning', 'CDeprecationWarning',
# Worker shutdown semi-predicates (inherits from SystemExit).
'WorkerShutdown', 'WorkerTerminate',
]
UNREGISTERED_FMT = """\
Task of kind {0} never registered, please make sure it's imported.\
"""
class CeleryWarning(UserWarning):
"""Base class for all Celery warnings."""
class AlwaysEagerIgnored(CeleryWarning):
"""send_task ignores :setting:`task_always_eager` option."""
class DuplicateNodenameWarning(CeleryWarning):
"""Multiple workers are using the same nodename."""
class FixupWarning(CeleryWarning):
"""Fixup related warning."""
class NotConfigured(CeleryWarning):
"""Celery hasn't been configured, as no config module has been found."""
class CeleryError(Exception):
"""Base class for all Celery errors."""
class TaskPredicate(CeleryError):
"""Base class for task-related semi-predicates."""
@python_2_unicode_compatible
class Retry(TaskPredicate):
"""The task is to be retried later."""
#: Optional message describing context of retry.
message = None
#: Exception (if any) that caused the retry to happen.
exc = None
#: Time of retry (ETA), either :class:`numbers.Real` or
#: :class:`~datetime.datetime`.
when = None
def __init__(self, message=None, exc=None, when=None, **kwargs):
from kombu.utils.encoding import safe_repr
self.message = message
if isinstance(exc, string_t):
self.exc, self.excs = None, exc
else:
self.exc, self.excs = exc, safe_repr(exc) if exc else None
self.when = when
super(Retry, self).__init__(self, exc, when, **kwargs)
def humanize(self):
if isinstance(self.when, numbers.Number):
return 'in {0.when}s'.format(self)
return 'at {0.when}'.format(self)
def __str__(self):
if self.message:
return self.message
if self.excs:
return 'Retry {0}: {1}'.format(self.humanize(), self.excs)
return 'Retry {0}'.format(self.humanize())
def __reduce__(self):
return self.__class__, (self.message, self.excs, self.when)
RetryTaskError = Retry # noqa: E305 XXX compat
class Ignore(TaskPredicate):
"""A task can raise this to ignore doing state updates."""
@python_2_unicode_compatible
class Reject(TaskPredicate):
"""A task can raise this if it wants to reject/re-queue the message."""
def __init__(self, reason=None, requeue=False):
self.reason = reason
self.requeue = requeue
super(Reject, self).__init__(reason, requeue)
def __repr__(self):
return 'reject requeue=%s: %s' % (self.requeue, self.reason)
class ImproperlyConfigured(CeleryError):
"""Celery is somehow improperly configured."""
class SecurityError(CeleryError):
"""Security related exception."""
class TaskError(CeleryError):
"""Task related errors."""
class QueueNotFound(KeyError, TaskError):
"""Task routed to a queue not in ``conf.queues``."""
class IncompleteStream(TaskError):
"""Found the end of a stream of data, but the data isn't complete."""
@python_2_unicode_compatible
class NotRegistered(KeyError, TaskError):
"""The task ain't registered."""
def __repr__(self):
return UNREGISTERED_FMT.format(self)
class AlreadyRegistered(TaskError):
"""The task is already registered."""
# XXX Unused
class TimeoutError(TaskError):
"""The operation timed out."""
class MaxRetriesExceededError(TaskError):
"""The tasks max restart limit has been exceeded."""
class TaskRevokedError(TaskError):
"""The task has been revoked, so no result available."""
class InvalidTaskError(TaskError):
"""The task has invalid data or ain't properly constructed."""
class ChordError(TaskError):
"""A task part of the chord raised an exception."""
class CPendingDeprecationWarning(PendingDeprecationWarning):
"""Warning of pending deprecation."""
class CDeprecationWarning(DeprecationWarning):
"""Warning of deprecation."""
class WorkerTerminate(SystemExit):
"""Signals that the worker should terminate immediately."""
SystemTerminate = WorkerTerminate # noqa: E305 XXX compat
class WorkerShutdown(SystemExit):
"""Signals that the worker should perform a warm shutdown."""
|