This document describes the current stable version of Celery (4.2). For development docs, go here.
celery.utils¶
Utility functions.
Don’t import from here directly anymore, as these are only here for backwards compatibility.
-
celery.utils.worker_direct(hostname)[source]¶ Return the
kombu.Queuebeing a direct route to a worker.Parameters: hostname (str, Queue) – The fully qualified node name of a worker (e.g., w1@example.com). If passed akombu.Queueinstance it will simply return that instead.
-
celery.utils.gen_task_name(app, name, module_name)[source]¶ Generate task name from name/module pair.
-
class
celery.utils.cached_property(fget=None, fset=None, fdel=None, doc=None)[source]¶ Cached property descriptor.
Caches the return value of the get method on first call.
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)