Worker Controller Threads - celery.worker.controllers
Worker Controller Threads
-
class celery.worker.controllers.BackgroundThread
Thread running an infinite loop which for every iteration
calls its on_iteration() method.
This also implements graceful shutdown of the thread by providing
the stop() method.
-
on_iteration()
- This is the method called for every iteration and must be
implemented by every subclass of BackgroundThread.
-
on_start()
- This handler is run at thread start, just before the infinite
loop.
-
on_stop()
- This handler is run when the thread is shutdown.
-
run()
This is the body of the thread.
To start the thread use start() instead.
-
stop()
- Gracefully shutdown the thread.
-
class celery.worker.controllers.Mediator(bucket_queue, callback)
Thread continuously sending tasks in the queue to the pool.
-
bucket_queue
- The task queue, a Queue.Queue instance.
-
callback
- The callback used to process tasks retrieved from the
bucket_queue.
-
on_iteration()
- Get tasks from bucket queue and apply the task callback.
-
class celery.worker.controllers.PeriodicWorkController(bucket_queue, hold_queue)
A thread that continuously checks if there are
celery.task.PeriodicTask tasks waiting for execution,
and executes them. It also finds tasks in the hold queue that is
ready for execution and moves them to the bucket queue.
(Tasks in the hold queue are tasks waiting for retry, or with an
eta/countdown.)
-
on_iteration()
- Run periodic tasks and process the hold queue.
-
on_start()
- Do backend-specific periodic task initialization.
-
process_hold_queue()
- Finds paused tasks that are ready for execution and move
them to the bucket_queue.