This document describes Celery 3.1. For development docs,
go here.
celery.utils
Utility functions.
-
celery.utils.worker_direct(hostname)[source]
Return kombu.Queue that is a direct route to
a worker by hostname.
| Parameters: | hostname – The fully qualified node name of a worker
(e.g. w1@example.com). If passed a
kombu.Queue instance it will simply return
that instead. |
-
celery.utils.warn_deprecated(description=None, deprecation=None, removal=None, alternative=None)[source]
-
celery.utils.deprecated(description=None, deprecation=None, removal=None, alternative=None)[source]
Decorator for deprecated functions.
A deprecation warning will be emitted when the function is called.
| Parameters: |
- description – Description of what is being deprecated.
- deprecation – Version that marks first deprecation, if this
argument is not set a PendingDeprecationWarning will be emitted
instead.
- removed – Future version when this feature will be removed.
- alternative – Instructions for an alternative solution (if any).
|
-
celery.utils.lpmerge(L, R)[source]
In place left precedent dictionary merge.
Keeps values from L, if the value in R is None.
-
celery.utils.is_iterable(obj)[source]
-
celery.utils.isatty(fh)[source]
-
celery.utils.cry(out=None, sepchr='=', seplen=49)[source]
Return stacktrace of all active threads,
taken from https://gist.github.com/737056.
-
celery.utils.maybe_reraise()[source]
Re-raise if an exception is currently being handled, or return
otherwise.
-
celery.utils.strtobool(term, table={'1': True, '0': False, 'false': False, 'no': False, 'off': False, 'yes': True, 'on': True, 'true': True})[source]
Convert common terms for true/false to bool
(true/false/yes/no/on/off/1/0).
-
celery.utils.jsonify(obj, builtin_types=(<type 'int'>, <type 'float'>, <type 'basestring'>), key=None, keyfilter=None, unknown_type_filter=None)[source]
Transforms object making it suitable for json serialization
-
celery.utils.gen_task_name(app, name, module_name)[source]
Generate task name from name/module pair.
-
celery.utils.nodename(name, hostname)[source]
Create node name from name/hostname pair.
-
celery.utils.nodesplit(nodename)[source]
Split node name into tuple of name/hostname.
-
class celery.utils.cached_property(fget=None, fset=None, fdel=None, doc=None)
Property descriptor that caches the return value
of the get function.
Examples
@cached_property
def connection(self):
return Connection()
@connection.setter # Prepares stored value
def connection(self, value):
if value is None:
raise TypeError('Connection must be a connection')
return value
@connection.deleter
def connection(self, value):
# Additional action to do at del(self.attr)
if value is not None:
print('Connection {0!r} deleted'.format(value)
-
deleter(fdel)
-
setter(fset)