This document describes an older version of Celery (2.5). For the latest stable version please go here.

celery.abstract

celery.abstract

Implements components and boot-steps.

copyright:
  1. 2009 - 2012 by Ask Solem.
license:

BSD, see LICENSE for more details.

class celery.abstract.Component(parent, **kwargs)

A component.

The __init__() method is called when the component is bound to a parent object, and can as such be used to initialize attributes in the parent object at parent instantiation-time.

abstract = None

if set the component will not be registered, but can be used as a component base class.

create(parent)

Create the component.

enabled = True

This provides the default for include_if().

include(parent)
include_if(parent)

An optional predicate that decided whether this component should be created.

instantiate(qualname, *args, **kwargs)
last = False

This flag is reserved for the workers Consumer, since it is required to always be started last. There can only be one object marked with lsat in every namespace.

name = None

The name of the component, or the namespace and the name of the component separated by dot.

namespace = None

can be used to specify the namespace, if the name does not include it.

obj = None

Optional obj created by the create() method. This is used by StartStopComponents to keep the original service object.

requires = ()

List of component names this component depends on. Note that the dependencies must be in the same namespace.

class celery.abstract.ComponentType

Metaclass for components.

class celery.abstract.Namespace(name=None, app=None, logger=None)

A namespace containing components.

Every component must belong to a namespace.

When component classes are created they are added to the mapping of unclaimed components. The components will be claimed when the namespace they belong to is created.

Parameters:
  • name – Set the name of this namespace.
  • app – Set the Celery app for this namespace.
apply(parent, **kwargs)

Apply the components in this namespace to an object.

This will apply the __init__ and include methods of each components with the object as argument.

For StartStopComponents the services created will also be added the the objects components attribute.

bind_component(name, parent, **kwargs)

Bind component to parent object and this namespace.

import_module(module)
load_modules()

Will load the component modules this namespace depends on.

modules()

Subclasses can override this to return a list of modules to import before components are claimed.

name = None
class celery.abstract.StartStopComponent(parent, **kwargs)
include(parent)
start()
stop()
terminable = False
terminate()

Previous topic

Internal Module Reference

Next topic

celery.worker

This Page