| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 | ======================= Internals: The worker=======================.. contents::    :local:Introduction============The worker consists of 4 main components: the broker listener, the scheduler,the mediator and the task pool. All these components runs in parallel workingwith two data structures: the ready queue and the ETA schedule... image:: http://cloud.github.com/downloads/ask/celery/Celery1.0-inside-worker.jpgData structures===============ready_queue-----------The ready queue is either an instance of :class:`Queue.Queue`, or`celery.buckets.TaskBucket`. The latter if rate limiting is enabled.eta_schedule------------The ETA schedule is a heap queue sorted by time.Components==========CarrotListener--------------Receives messages from the broker using ``carrot``.When a message is received it's converted into a:class:`celery.worker.job.TaskRequest` object.Tasks with an ETA are entered into the ``eta_schedule``, messages that canbe immediately processed are moved directly to the ``ready_queue``.ScheduleController------------------The schedule controller is running the ``eta_schedule``.If the scheduled tasks eta has passed it is moved to the ``ready_queue``,otherwise the thread sleeps until the eta is met (remember that the scheduleis sorted by time).Mediator--------The mediator simply moves tasks in the ``ready_queue`` over to thetask pool for execution using:meth:`celery.worker.job.TaskRequest.execute_using_pool`.TaskPool--------This is a slightly modified :class:`multiprocessing.Pool`.It mostly works the same way, except it makes sure all of the workersare running at all times. If a worker is missing, it replacesit with a new one.
 |