| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240 | <!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>Task Pool - celery.pool — Celery v0.3.12 (unstable) 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.3.12 (unstable)',        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.3.12 (unstable) documentation" href="../index.html" />    <link rel="up" title="Module API Reference" href="index.html" />    <link rel="next" title="Backends - celery.backends" href="celery.backends.html" />    <link rel="prev" title="Multiprocessing Worker - celery.worker" href="celery.worker.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.backends.html" title="Backends - celery.backends"             accesskey="N">next</a> |</li>        <li class="right" >          <a href="celery.worker.html" title="Multiprocessing Worker - celery.worker"             accesskey="P">previous</a> |</li>        <li><a href="../index.html">Celery v0.3.12 (unstable) 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.pool"><h1>Task Pool - celery.pool<a class="headerlink" href="#module-celery.pool" title="Permalink to this headline">¶</a></h1><p>Process Pools.</p><dl class="class"><dt id="celery.pool.TaskPool"><em class="property">class </em><tt class="descclassname">celery.pool.</tt><tt class="descname">TaskPool</tt><big>(</big><em>limit</em>, <em>logger=None</em><big>)</big><a class="headerlink" href="#celery.pool.TaskPool" title="Permalink to this definition">¶</a></dt><dd><p>Pool of running child processes, which starts waiting for theprocesses to finish when the queue limit has been reached.</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>limit</em> – see <a title="celery.pool.TaskPool.limit" class="reference internal" href="#celery.pool.TaskPool.limit"><tt class="xref docutils literal"><span class="pre">limit</span></tt></a> attribute.</li><li><em>logger</em> – see <a title="celery.pool.TaskPool.logger" class="reference internal" href="#celery.pool.TaskPool.logger"><tt class="xref docutils literal"><span class="pre">logger</span></tt></a> attribute.</li></ul></td></tr></tbody></table><dl class="attribute"><dt id="celery.pool.TaskPool.limit"><tt class="descname">limit</tt><a class="headerlink" href="#celery.pool.TaskPool.limit" title="Permalink to this definition">¶</a></dt><dd>The number of processes that can run simultaneously untilwe start collecting results.</dd></dl><dl class="attribute"><dt id="celery.pool.TaskPool.logger"><tt class="descname">logger</tt><a class="headerlink" href="#celery.pool.TaskPool.logger" title="Permalink to this definition">¶</a></dt><dd>The logger used for debugging.</dd></dl><dl class="method"><dt id="celery.pool.TaskPool.add"><tt class="descname">add</tt><big>(</big><em>result</em>, <em>callbacks</em>, <em>errbacks</em>, <em>tid</em>, <em>meta</em><big>)</big><a class="headerlink" href="#celery.pool.TaskPool.add" title="Permalink to this definition">¶</a></dt><dd><p>Add a process to the queue.</p><p>If the queue is full, it will wait for the first task to finish,collects its result and remove it from the queue, so it’s readyto accept new processes.</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">Parameter:</th><td class="field-body"><em>result</em> – A <tt class="xref docutils literal"><span class="pre">multiprocessing.AsyncResult</span></tt> instance, asreturned by <tt class="xref docutils literal"><span class="pre">multiprocessing.Pool.apply_async()</span></tt>.</td></tr><tr class="field"><th class="field-name" colspan="2">Option callbacks:</th></tr><tr><td> </td><td class="field-body">List of callbacks to execute if the task wassuccessful. Must have the function signature:<tt class="docutils literal"><span class="pre">mycallback(result,</span> <span class="pre">meta)</span></tt></td></tr><tr class="field"><th class="field-name" colspan="2">Option errbacks:</th></tr><tr><td> </td><td class="field-body">List of errbacks to execute if the task raisedand exception. Must have the function signature:<tt class="docutils literal"><span class="pre">myerrback(exc,</span> <span class="pre">meta)</span></tt>.</td></tr><tr class="field"><th class="field-name">Option tid:</th><td class="field-body">The tid for this task (unqiue pool id).</td></tr></tbody></table></dd></dl><dl class="method"><dt id="celery.pool.TaskPool.apply_async"><tt class="descname">apply_async</tt><big>(</big><em>target</em>, <em>args=None</em>, <em>kwargs=None</em>, <em>callbacks=None</em>, <em>errbacks=None</em>, <em>on_acknowledge=None</em>, <em>meta=None</em><big>)</big><a class="headerlink" href="#celery.pool.TaskPool.apply_async" title="Permalink to this definition">¶</a></dt><dd><p>Equivalent of the :func:<tt class="docutils literal"><span class="pre">apply</span></tt> built-in function.</p><p>All <tt class="docutils literal"><span class="pre">callbacks</span></tt> and <tt class="docutils literal"><span class="pre">errbacks</span></tt> should complete immediately sinceotherwise the thread which handles the result will get blocked.</p></dd></dl><dl class="method"><dt id="celery.pool.TaskPool.full"><tt class="descname">full</tt><big>(</big><big>)</big><a class="headerlink" href="#celery.pool.TaskPool.full" title="Permalink to this definition">¶</a></dt><dd><p>Is the pool full?</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">Returns:</th><td class="field-body"><tt class="xref docutils literal"><span class="pre">True</span></tt> if the maximum number of concurrent processeshas been reached.</td></tr></tbody></table></dd></dl><dl class="method"><dt id="celery.pool.TaskPool.get_worker_pids"><tt class="descname">get_worker_pids</tt><big>(</big><big>)</big><a class="headerlink" href="#celery.pool.TaskPool.get_worker_pids" title="Permalink to this definition">¶</a></dt><dd>Returns the process id’s of all the pool workers.</dd></dl><dl class="method"><dt id="celery.pool.TaskPool.on_ready"><tt class="descname">on_ready</tt><big>(</big><em>ret_value</em>, <em>callbacks</em>, <em>errbacks</em>, <em>meta</em><big>)</big><a class="headerlink" href="#celery.pool.TaskPool.on_ready" title="Permalink to this definition">¶</a></dt><dd>What to do when a worker task is ready and its return value hasbeen collected.</dd></dl><dl class="method"><dt id="celery.pool.TaskPool.on_return"><tt class="descname">on_return</tt><big>(</big><em>ret_val</em>, <em>tid</em>, <em>callbacks</em>, <em>errbacks</em>, <em>meta</em><big>)</big><a class="headerlink" href="#celery.pool.TaskPool.on_return" title="Permalink to this definition">¶</a></dt><dd>What to do when the process returns.</dd></dl><dl class="method"><dt id="celery.pool.TaskPool.reap"><tt class="descname">reap</tt><big>(</big><big>)</big><a class="headerlink" href="#celery.pool.TaskPool.reap" title="Permalink to this definition">¶</a></dt><dd>Reap finished tasks.</dd></dl><dl class="method"><dt id="celery.pool.TaskPool.run"><tt class="descname">run</tt><big>(</big><big>)</big><a class="headerlink" href="#celery.pool.TaskPool.run" title="Permalink to this definition">¶</a></dt><dd><p>Run the task pool.</p><p>Will pre-fork all workers so they’re ready to accept tasks.</p></dd></dl><dl class="method"><dt id="celery.pool.TaskPool.terminate"><tt class="descname">terminate</tt><big>(</big><big>)</big><a class="headerlink" href="#celery.pool.TaskPool.terminate" title="Permalink to this definition">¶</a></dt><dd>Terminate the pool.</dd></dl><dl class="method"><dt id="celery.pool.TaskPool.wait_for_result"><tt class="descname">wait_for_result</tt><big>(</big><big>)</big><a class="headerlink" href="#celery.pool.TaskPool.wait_for_result" title="Permalink to this definition">¶</a></dt><dd><p>Waits for the first process in the pool to finish.</p><p>This operation is blocking.</p></dd></dl></dd></dl></div>          </div>        </div>      </div>      <div class="sphinxsidebar">        <div class="sphinxsidebarwrapper">            <h4>Previous topic</h4>            <p class="topless"><a href="celery.worker.html"                                  title="previous chapter">Multiprocessing Worker - celery.worker</a></p>            <h4>Next topic</h4>            <p class="topless"><a href="celery.backends.html"                                  title="next chapter">Backends - celery.backends</a></p>            <h3>This Page</h3>            <ul class="this-page-menu">              <li><a href="../sources/reference/celery.pool.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.backends.html" title="Backends - celery.backends"             >next</a> |</li>        <li class="right" >          <a href="celery.worker.html" title="Multiprocessing Worker - celery.worker"             >previous</a> |</li>        <li><a href="../index.html">Celery v0.3.12 (unstable) 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>
 |