celery.utils
celery.utils
Utility functions.
celery.utils.worker_direct(hostname)[源代码]
Return kombu.Queue that is a direct route to a worker by hostname.
参数: | 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, stacklevel=2)[源代码]
celery.utils.deprecated(deprecation=None, removal=None, alternative=None, description=None)[源代码]
Decorator for deprecated functions.
A deprecation warning will be emitted when the function is called.
参数: |
|
---|
celery.utils.lpmerge(L, R)[源代码]
In place left precedent dictionary merge.
Keeps values from L, if the value in R is None.
celery.utils.is_iterable(obj)[源代码]
celery.utils.isatty(fh)[源代码]
celery.utils.cry(out=None, sepchr=’=’, seplen=49)[源代码]
Return stacktrace of all active threads, taken from https://gist.github.com/737056.
celery.utils.maybe_reraise()[源代码]
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})[源代码]
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)[源代码]
Transforms object making it suitable for json serialization
celery.utils.gen_task_name(app, name, module_name)[源代码]
Generate task name from name/module pair.
celery.utils.nodename(name, hostname)
Create node name from name/hostname pair.
celery.utils.nodesplit(nodename)
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)