This document describes Celery 3.0. For development docs, go here.

celery.utils

celery.utils

Utility functions.

celery.utils.MP_MAIN_FILE = None

Billiard sets this when execv is enabled. We use it to find out the name of the original __main__ module, so that we can properly rewrite the name of the task to be that of App.main.

celery.utils.WORKER_DIRECT_EXCHANGE = <unbound Exchange C.dq(direct)>

Exchange for worker direct queues.

celery.utils.WORKER_DIRECT_QUEUE_FORMAT = '%s.dq'

Format for worker direct queue names.

celery.utils.cry()[source]

Return stacktrace of all active threads.

From https://gist.github.com/737056

celery.utils.deprecated(description=None, deprecation=None, removal=None, alternative=None)[source]
celery.utils.fun_takes_kwargs(fun, kwlist=[])[source]

With a function, and a list of keyword arguments, returns arguments in the list which the function takes.

If the object has an argspec attribute that is used instead of using the inspect.getargspec() introspection.

Parameters:
  • fun – The function to inspect arguments of.
  • kwlist – The list of keyword arguments.

Examples

>>> def foo(self, x, y, logfile=None, loglevel=None):
...     return x * y
>>> fun_takes_kwargs(foo, ['logfile', 'loglevel', 'task_id'])
['logfile', 'loglevel']
>>> def foo(self, x, y, **kwargs):
>>> fun_takes_kwargs(foo, ['logfile', 'loglevel', 'task_id'])
['logfile', 'loglevel', 'task_id']
celery.utils.gen_task_name(app, name, module_name)[source]
celery.utils.is_iterable(obj)[source]
celery.utils.isatty(fh)[source]
celery.utils.jsonify(obj)[source]

Transforms object making it suitable for json serialization

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.maybe_reraise()[source]

Reraise 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]
celery.utils.warn_deprecated(description=None, deprecation=None, removal=None, alternative=None)[source]
celery.utils.worker_direct(hostname)[source]

Previous topic

celery.backends.database.session

Next topic

celery.utils.functional

This Page