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.Queue being 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 a kombu.Queue instance it will simply return that instead.
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(name)[source]

Split node name into tuple of name/hostname.

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)
deleter(fdel)[source]
setter(fset)[source]
celery.utils.uuid(_uuid=<function uuid4>)[source]

Generate unique id in UUID4 format.

See also

For now this is provided by uuid.uuid4().