| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml">  <head>    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />        <title>Multiprocessing Worker - celery.worker — Celery v0.4.12 (stable) documentation</title>    <link rel="stylesheet" href="../static/nature.css" type="text/css" />    <link rel="stylesheet" href="../static/pygments.css" type="text/css" />    <script type="text/javascript">      var DOCUMENTATION_OPTIONS = {        URL_ROOT:    '../',        VERSION:     '0.4.12 (stable)',        COLLAPSE_MODINDEX: false,        FILE_SUFFIX: '.html',        HAS_SOURCE:  true      };    </script>    <script type="text/javascript" src="../static/jquery.js"></script>    <script type="text/javascript" src="../static/doctools.js"></script>    <link rel="top" title="Celery v0.4.12 (stable) documentation" href="../index.html" />    <link rel="up" title="Module API Reference" href="index.html" />    <link rel="next" title="Executable Jobs - celery.worker.job" href="celery.worker.job.html" />    <link rel="prev" title="Messaging - celery.messaging" href="celery.messaging.html" />   </head>  <body>    <div class="related">      <h3>Navigation</h3>      <ul>        <li class="right" style="margin-right: 10px">          <a href="../genindex.html" title="General Index"             accesskey="I">index</a></li>        <li class="right" >          <a href="../modindex.html" title="Global Module Index"             accesskey="M">modules</a> |</li>        <li class="right" >          <a href="celery.worker.job.html" title="Executable Jobs - celery.worker.job"             accesskey="N">next</a> |</li>        <li class="right" >          <a href="celery.messaging.html" title="Messaging - celery.messaging"             accesskey="P">previous</a> |</li>        <li><a href="../index.html">Celery v0.4.12 (stable) documentation</a> »</li>          <li><a href="index.html" accesskey="U">Module API Reference</a> »</li>       </ul>    </div>      <div class="document">      <div class="documentwrapper">        <div class="bodywrapper">          <div class="body">              <div class="section" id="module-celery.worker"><h1>Multiprocessing Worker - celery.worker<a class="headerlink" href="#module-celery.worker" title="Permalink to this headline">¶</a></h1><p>The Multiprocessing Worker Server</p><p>Documentation for this module is in <tt class="docutils literal"><span class="pre">docs/reference/celery.worker.rst</span></tt>.</p><dl class="class"><dt id="celery.worker.AMQPListener"><em class="property">class </em><tt class="descclassname">celery.worker.</tt><tt class="descname">AMQPListener</tt><big>(</big><em>bucket_queue</em>, <em>hold_queue</em>, <em>logger</em><big>)</big><a class="headerlink" href="#celery.worker.AMQPListener" title="Permalink to this definition">¶</a></dt><dd><p>Listen for messages received from the AMQP broker andmove them the the bucket queue for task processing.</p><table class="docutils field-list" frame="void" rules="none"><col class="field-name" /><col class="field-body" /><tbody valign="top"><tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple"><li><em>bucket_queue</em> – See <a title="celery.worker.AMQPListener.bucket_queue" class="reference internal" href="#celery.worker.AMQPListener.bucket_queue"><tt class="xref docutils literal"><span class="pre">bucket_queue</span></tt></a>.</li><li><em>hold_queue</em> – See <a title="celery.worker.AMQPListener.hold_queue" class="reference internal" href="#celery.worker.AMQPListener.hold_queue"><tt class="xref docutils literal"><span class="pre">hold_queue</span></tt></a>.</li></ul></td></tr></tbody></table><dl class="attribute"><dt id="celery.worker.AMQPListener.bucket_queue"><tt class="descname">bucket_queue</tt><a class="headerlink" href="#celery.worker.AMQPListener.bucket_queue" title="Permalink to this definition">¶</a></dt><dd>The queue that holds tasks ready for processing immediately.</dd></dl><dl class="attribute"><dt id="celery.worker.AMQPListener.hold_queue"><tt class="descname">hold_queue</tt><a class="headerlink" href="#celery.worker.AMQPListener.hold_queue" title="Permalink to this definition">¶</a></dt><dd>The queue that holds paused tasks. Reasons for being paused includea countdown/eta or that it’s waiting for retry.</dd></dl><dl class="attribute"><dt id="celery.worker.AMQPListener.logger"><tt class="descname">logger</tt><a class="headerlink" href="#celery.worker.AMQPListener.logger" title="Permalink to this definition">¶</a></dt><dd>The logger used.</dd></dl><dl class="method"><dt id="celery.worker.AMQPListener.close_connection"><tt class="descname">close_connection</tt><big>(</big><big>)</big><a class="headerlink" href="#celery.worker.AMQPListener.close_connection" title="Permalink to this definition">¶</a></dt><dd>Close the AMQP connection.</dd></dl><dl class="method"><dt id="celery.worker.AMQPListener.receive_message"><tt class="descname">receive_message</tt><big>(</big><em>message_data</em>, <em>message</em><big>)</big><a class="headerlink" href="#celery.worker.AMQPListener.receive_message" title="Permalink to this definition">¶</a></dt><dd><p>The callback called when a new message is received.</p><p>If the message has an <tt class="docutils literal"><span class="pre">eta</span></tt> we move it to the hold queue,otherwise we move it the bucket queue for immediate processing.</p></dd></dl><dl class="method"><dt id="celery.worker.AMQPListener.reset_connection"><tt class="descname">reset_connection</tt><big>(</big><big>)</big><a class="headerlink" href="#celery.worker.AMQPListener.reset_connection" title="Permalink to this definition">¶</a></dt><dd><p>Reset the AMQP connection, and reinitialize the<a title="celery.messaging.TaskConsumer" class="reference external" href="celery.messaging.html#celery.messaging.TaskConsumer"><tt class="xref docutils literal"><span class="pre">celery.messaging.TaskConsumer</span></tt></a> instance.</p><p>Resets the task consumer in <tt class="xref docutils literal"><span class="pre">task_consumer</span></tt>.</p></dd></dl><dl class="method"><dt id="celery.worker.AMQPListener.start"><tt class="descname">start</tt><big>(</big><big>)</big><a class="headerlink" href="#celery.worker.AMQPListener.start" title="Permalink to this definition">¶</a></dt><dd>Start processing AMQP messages.</dd></dl><dl class="method"><dt id="celery.worker.AMQPListener.stop"><tt class="descname">stop</tt><big>(</big><big>)</big><a class="headerlink" href="#celery.worker.AMQPListener.stop" title="Permalink to this definition">¶</a></dt><dd>Stop processing AMQP messages and close the connectionto the broker.</dd></dl></dd></dl><dl class="class"><dt id="celery.worker.WorkController"><em class="property">class </em><tt class="descclassname">celery.worker.</tt><tt class="descname">WorkController</tt><big>(</big><em>concurrency=None</em>, <em>logfile=None</em>, <em>loglevel=None</em>, <em>is_detached=False</em><big>)</big><a class="headerlink" href="#celery.worker.WorkController" title="Permalink to this definition">¶</a></dt><dd><p>Executes tasks waiting in the task queue.</p><table class="docutils field-list" frame="void" rules="none"><col class="field-name" /><col class="field-body" /><tbody valign="top"><tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple"><li><em>concurrency</em> – see <a title="celery.worker.WorkController.concurrency" class="reference internal" href="#celery.worker.WorkController.concurrency"><tt class="xref docutils literal"><span class="pre">concurrency</span></tt></a>.</li><li><em>logfile</em> – see <a title="celery.worker.WorkController.logfile" class="reference internal" href="#celery.worker.WorkController.logfile"><tt class="xref docutils literal"><span class="pre">logfile</span></tt></a>.</li><li><em>loglevel</em> – see <a title="celery.worker.WorkController.loglevel" class="reference internal" href="#celery.worker.WorkController.loglevel"><tt class="xref docutils literal"><span class="pre">loglevel</span></tt></a>.</li></ul></td></tr></tbody></table><dl class="attribute"><dt id="celery.worker.WorkController.concurrency"><tt class="descname">concurrency</tt><a class="headerlink" href="#celery.worker.WorkController.concurrency" title="Permalink to this definition">¶</a></dt><dd>The number of simultaneous processes doing work (default:<a title="celery.conf.DAEMON_CONCURRENCY" class="reference external" href="celery.conf.html#celery.conf.DAEMON_CONCURRENCY"><tt class="xref docutils literal"><span class="pre">celery.conf.DAEMON_CONCURRENCY</span></tt></a>)</dd></dl><dl class="attribute"><dt id="celery.worker.WorkController.loglevel"><tt class="descname">loglevel</tt><a class="headerlink" href="#celery.worker.WorkController.loglevel" title="Permalink to this definition">¶</a></dt><dd>The loglevel used (default: <tt class="xref docutils literal"><span class="pre">logging.INFO</span></tt>)</dd></dl><dl class="attribute"><dt id="celery.worker.WorkController.logfile"><tt class="descname">logfile</tt><a class="headerlink" href="#celery.worker.WorkController.logfile" title="Permalink to this definition">¶</a></dt><dd>The logfile used, if no logfile is specified it uses <tt class="docutils literal"><span class="pre">stderr</span></tt>(default: <a title="celery.conf.DAEMON_LOG_FILE" class="reference external" href="celery.conf.html#celery.conf.DAEMON_LOG_FILE"><tt class="xref docutils literal"><span class="pre">celery.conf.DAEMON_LOG_FILE</span></tt></a>).</dd></dl><dl class="attribute"><dt id="celery.worker.WorkController.logger"><tt class="descname">logger</tt><a class="headerlink" href="#celery.worker.WorkController.logger" title="Permalink to this definition">¶</a></dt><dd>The <tt class="xref docutils literal"><span class="pre">logging.Logger</span></tt> instance used for logging.</dd></dl><dl class="attribute"><dt id="celery.worker.WorkController.is_detached"><tt class="descname">is_detached</tt><a class="headerlink" href="#celery.worker.WorkController.is_detached" title="Permalink to this definition">¶</a></dt><dd>Flag describing if the worker is running as a daemon or not.</dd></dl><dl class="attribute"><dt id="celery.worker.WorkController.pool"><tt class="descname">pool</tt><a class="headerlink" href="#celery.worker.WorkController.pool" title="Permalink to this definition">¶</a></dt><dd>The <tt class="xref docutils literal"><span class="pre">multiprocessing.Pool</span></tt> instance used.</dd></dl><dl class="attribute"><dt id="celery.worker.WorkController.bucket_queue"><tt class="descname">bucket_queue</tt><a class="headerlink" href="#celery.worker.WorkController.bucket_queue" title="Permalink to this definition">¶</a></dt><dd>The <tt class="xref docutils literal"><span class="pre">Queue.Queue</span></tt> that holds tasks ready for immediateprocessing.</dd></dl><dl class="attribute"><dt id="celery.worker.WorkController.hold_queue"><tt class="descname">hold_queue</tt><a class="headerlink" href="#celery.worker.WorkController.hold_queue" title="Permalink to this definition">¶</a></dt><dd>The <tt class="xref docutils literal"><span class="pre">Queue.Queue</span></tt> that holds paused tasks. Reasons for holdingback the task include waiting for <tt class="docutils literal"><span class="pre">eta</span></tt> to pass or the task is beingretried.</dd></dl><dl class="attribute"><dt id="celery.worker.WorkController.periodic_work_controller"><tt class="descname">periodic_work_controller</tt><a class="headerlink" href="#celery.worker.WorkController.periodic_work_controller" title="Permalink to this definition">¶</a></dt><dd>Instance of <a title="celery.worker.controllers.PeriodicWorkController" class="reference external" href="celery.worker.controllers.html#celery.worker.controllers.PeriodicWorkController"><tt class="xref docutils literal"><span class="pre">celery.worker.controllers.PeriodicWorkController</span></tt></a>.</dd></dl><dl class="attribute"><dt id="celery.worker.WorkController.mediator"><tt class="descname">mediator</tt><a class="headerlink" href="#celery.worker.WorkController.mediator" title="Permalink to this definition">¶</a></dt><dd>Instance of <a title="celery.worker.controllers.Mediator" class="reference external" href="celery.worker.controllers.html#celery.worker.controllers.Mediator"><tt class="xref docutils literal"><span class="pre">celery.worker.controllers.Mediator</span></tt></a>.</dd></dl><dl class="attribute"><dt id="celery.worker.WorkController.amqp_listener"><tt class="descname">amqp_listener</tt><a class="headerlink" href="#celery.worker.WorkController.amqp_listener" title="Permalink to this definition">¶</a></dt><dd>Instance of <a title="celery.worker.AMQPListener" class="reference internal" href="#celery.worker.AMQPListener"><tt class="xref docutils literal"><span class="pre">AMQPListener</span></tt></a>.</dd></dl><dl class="method"><dt id="celery.worker.WorkController.process_task"><tt class="descname">process_task</tt><big>(</big><em>task</em><big>)</big><a class="headerlink" href="#celery.worker.WorkController.process_task" title="Permalink to this definition">¶</a></dt><dd>Process task by sending it to the pool of workers.</dd></dl><dl class="method"><dt id="celery.worker.WorkController.safe_process_task"><tt class="descname">safe_process_task</tt><big>(</big><em>task</em><big>)</big><a class="headerlink" href="#celery.worker.WorkController.safe_process_task" title="Permalink to this definition">¶</a></dt><dd>Same as <a title="celery.worker.WorkController.process_task" class="reference internal" href="#celery.worker.WorkController.process_task"><tt class="xref docutils literal"><span class="pre">process_task()</span></tt></a>, but catches all exceptionsthe task raises and log them as errors, to make sure theworker doesn’t die.</dd></dl><dl class="method"><dt id="celery.worker.WorkController.start"><tt class="descname">start</tt><big>(</big><big>)</big><a class="headerlink" href="#celery.worker.WorkController.start" title="Permalink to this definition">¶</a></dt><dd>Starts the workers main loop.</dd></dl><dl class="method"><dt id="celery.worker.WorkController.stop"><tt class="descname">stop</tt><big>(</big><big>)</big><a class="headerlink" href="#celery.worker.WorkController.stop" title="Permalink to this definition">¶</a></dt><dd>Gracefully shutdown the worker server.</dd></dl></dd></dl></div>          </div>        </div>      </div>      <div class="sphinxsidebar">        <div class="sphinxsidebarwrapper">            <h4>Previous topic</h4>            <p class="topless"><a href="celery.messaging.html"                                  title="previous chapter">Messaging - celery.messaging</a></p>            <h4>Next topic</h4>            <p class="topless"><a href="celery.worker.job.html"                                  title="next chapter">Executable Jobs - celery.worker.job</a></p>            <h3>This Page</h3>            <ul class="this-page-menu">              <li><a href="../sources/reference/celery.worker.txt"                     rel="nofollow">Show Source</a></li>            </ul>          <div id="searchbox" style="display: none">            <h3>Quick search</h3>              <form class="search" action="../search.html" method="get">                <input type="text" name="q" size="18" />                <input type="submit" value="Go" />                <input type="hidden" name="check_keywords" value="yes" />                <input type="hidden" name="area" value="default" />              </form>              <p class="searchtip" style="font-size: 90%">              Enter search terms or a module, class or function name.              </p>          </div>          <script type="text/javascript">$('#searchbox').show(0);</script>        </div>      </div>      <div class="clearer"></div>    </div>    <div class="related">      <h3>Navigation</h3>      <ul>        <li class="right" style="margin-right: 10px">          <a href="../genindex.html" title="General Index"             >index</a></li>        <li class="right" >          <a href="../modindex.html" title="Global Module Index"             >modules</a> |</li>        <li class="right" >          <a href="celery.worker.job.html" title="Executable Jobs - celery.worker.job"             >next</a> |</li>        <li class="right" >          <a href="celery.messaging.html" title="Messaging - celery.messaging"             >previous</a> |</li>        <li><a href="../index.html">Celery v0.4.12 (stable) documentation</a> »</li>          <li><a href="index.html" >Module API Reference</a> »</li>       </ul>    </div>    <div class="footer">      © Copyright 2009, Ask Solem.      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 0.6.1.    </div>  </body></html>
 |