worker.worker

WorkController can be used to instantiate in-process workers.

The command-line interface for the worker is in celery.bin.worker, while the worker program is in celery.apps.worker.

The worker program is responsible for adding signal handlers, setting up logging, etc. This is a bare-bones worker without global side-effects (i.e., except for the global state stored in celery.worker.state).

The worker consists of several components, all managed by bootsteps (mod:celery.bootsteps).

Module Contents

Classes

WorkController(self,app=None,hostname=None,**kwargs) Unmanaged worker instance.
class WorkController(app=None, hostname=None, **kwargs)

Unmanaged worker instance.

class Blueprint

Worker bootstep blueprint.

__init__(app=None, hostname=None, **kwargs)
setup_instance(queues=None, ready_callback=None, pidfile=None, include=None, use_eventloop=None, exclude_queues=None, **kwargs)
on_init_blueprint()
on_before_init(**kwargs)
on_after_init(**kwargs)
on_start()
on_consumer_ready(consumer)
on_close()
on_stopped()
setup_queues(include, exclude=None)
setup_includes(includes)
prepare_args(**kwargs)
_send_worker_shutdown()
start()
register_with_event_loop(hub)
_process_task_sem(req)
_process_task(req)

Process task by sending it to the pool of workers.

signal_consumer_close()
should_use_eventloop()
stop(in_sighandler=False, exitcode=None)

Graceful shutdown of the worker server.

terminate(in_sighandler=False)

Not so graceful shutdown of the worker server.

_shutdown(warm=True)
reload(modules=None, reload=False, reloader=None)
_reload_modules(modules=None, **kwargs)
_maybe_reload_module(module, force_reload=False, reloader=None)
info()
rusage()
stats()
__repr__()

repr(worker).

__str__()

str(worker) == worker.hostname.

state()
setup_defaults(concurrency=None, loglevel="WARN", logfile=None, task_events=None, pool=None, consumer_cls=None, timer_cls=None, timer_precision=None, autoscaler_cls=None, pool_putlocks=None, pool_restarts=None, optimization=None, O=None, statedb=None, time_limit=None, soft_time_limit=None, scheduler=None, pool_cls=None, state_db=None, task_time_limit=None, task_soft_time_limit=None, scheduler_cls=None, schedule_filename=None, max_tasks_per_child=None, prefetch_multiplier=None, disable_rate_limits=None, worker_lost_wait=None, max_memory_per_child=None, **_kw)