celery.pool.html 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml">
  4. <head>
  5. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  6. <title>Task Pool - celery.pool &mdash; Celery v0.3.12 (unstable) documentation</title>
  7. <link rel="stylesheet" href="../static/nature.css" type="text/css" />
  8. <link rel="stylesheet" href="../static/pygments.css" type="text/css" />
  9. <script type="text/javascript">
  10. var DOCUMENTATION_OPTIONS = {
  11. URL_ROOT: '../',
  12. VERSION: '0.3.12 (unstable)',
  13. COLLAPSE_MODINDEX: false,
  14. FILE_SUFFIX: '.html',
  15. HAS_SOURCE: true
  16. };
  17. </script>
  18. <script type="text/javascript" src="../static/jquery.js"></script>
  19. <script type="text/javascript" src="../static/doctools.js"></script>
  20. <link rel="top" title="Celery v0.3.12 (unstable) documentation" href="../index.html" />
  21. <link rel="up" title="Module API Reference" href="index.html" />
  22. <link rel="next" title="Backends - celery.backends" href="celery.backends.html" />
  23. <link rel="prev" title="Multiprocessing Worker - celery.worker" href="celery.worker.html" />
  24. </head>
  25. <body>
  26. <div class="related">
  27. <h3>Navigation</h3>
  28. <ul>
  29. <li class="right" style="margin-right: 10px">
  30. <a href="../genindex.html" title="General Index"
  31. accesskey="I">index</a></li>
  32. <li class="right" >
  33. <a href="../modindex.html" title="Global Module Index"
  34. accesskey="M">modules</a> |</li>
  35. <li class="right" >
  36. <a href="celery.backends.html" title="Backends - celery.backends"
  37. accesskey="N">next</a> |</li>
  38. <li class="right" >
  39. <a href="celery.worker.html" title="Multiprocessing Worker - celery.worker"
  40. accesskey="P">previous</a> |</li>
  41. <li><a href="../index.html">Celery v0.3.12 (unstable) documentation</a> &raquo;</li>
  42. <li><a href="index.html" accesskey="U">Module API Reference</a> &raquo;</li>
  43. </ul>
  44. </div>
  45. <div class="document">
  46. <div class="documentwrapper">
  47. <div class="bodywrapper">
  48. <div class="body">
  49. <div class="section" id="module-celery.pool">
  50. <h1>Task Pool - celery.pool<a class="headerlink" href="#module-celery.pool" title="Permalink to this headline">¶</a></h1>
  51. <p>Process Pools.</p>
  52. <dl class="class">
  53. <dt id="celery.pool.TaskPool">
  54. <em class="property">
  55. 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>
  56. <dd><p>Pool of running child processes, which starts waiting for the
  57. processes to finish when the queue limit has been reached.</p>
  58. <table class="docutils field-list" frame="void" rules="none">
  59. <col class="field-name" />
  60. <col class="field-body" />
  61. <tbody valign="top">
  62. <tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
  63. <li><em>limit</em> &#8211; 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>
  64. <li><em>logger</em> &#8211; 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>
  65. </ul>
  66. </td>
  67. </tr>
  68. </tbody>
  69. </table>
  70. <dl class="attribute">
  71. <dt id="celery.pool.TaskPool.limit">
  72. <tt class="descname">limit</tt><a class="headerlink" href="#celery.pool.TaskPool.limit" title="Permalink to this definition">¶</a></dt>
  73. <dd>The number of processes that can run simultaneously until
  74. we start collecting results.</dd></dl>
  75. <dl class="attribute">
  76. <dt id="celery.pool.TaskPool.logger">
  77. <tt class="descname">logger</tt><a class="headerlink" href="#celery.pool.TaskPool.logger" title="Permalink to this definition">¶</a></dt>
  78. <dd>The logger used for debugging.</dd></dl>
  79. <dl class="method">
  80. <dt id="celery.pool.TaskPool.add">
  81. <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>
  82. <dd><p>Add a process to the queue.</p>
  83. <p>If the queue is full, it will wait for the first task to finish,
  84. collects its result and remove it from the queue, so it&#8217;s ready
  85. to accept new processes.</p>
  86. <table class="docutils field-list" frame="void" rules="none">
  87. <col class="field-name" />
  88. <col class="field-body" />
  89. <tbody valign="top">
  90. <tr class="field"><th class="field-name">Parameter:</th><td class="field-body"><em>result</em> &#8211; A <tt class="xref docutils literal"><span class="pre">multiprocessing.AsyncResult</span></tt> instance, as
  91. returned by <tt class="xref docutils literal"><span class="pre">multiprocessing.Pool.apply_async()</span></tt>.</td>
  92. </tr>
  93. <tr class="field"><th class="field-name" colspan="2">Option callbacks:</th></tr>
  94. <tr><td>&nbsp;</td><td class="field-body">List of callbacks to execute if the task was
  95. successful. Must have the function signature:
  96. <tt class="docutils literal"><span class="pre">mycallback(result,</span> <span class="pre">meta)</span></tt></td>
  97. </tr>
  98. <tr class="field"><th class="field-name" colspan="2">Option errbacks:</th></tr>
  99. <tr><td>&nbsp;</td><td class="field-body">List of errbacks to execute if the task raised
  100. and exception. Must have the function signature:
  101. <tt class="docutils literal"><span class="pre">myerrback(exc,</span> <span class="pre">meta)</span></tt>.</td>
  102. </tr>
  103. <tr class="field"><th class="field-name">Option tid:</th><td class="field-body">The tid for this task (unqiue pool id).</td>
  104. </tr>
  105. </tbody>
  106. </table>
  107. </dd></dl>
  108. <dl class="method">
  109. <dt id="celery.pool.TaskPool.apply_async">
  110. <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>
  111. <dd><p>Equivalent of the :func:<tt class="docutils literal"><span class="pre">apply</span></tt> built-in function.</p>
  112. <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 since
  113. otherwise the thread which handles the result will get blocked.</p>
  114. </dd></dl>
  115. <dl class="method">
  116. <dt id="celery.pool.TaskPool.full">
  117. <tt class="descname">full</tt><big>(</big><big>)</big><a class="headerlink" href="#celery.pool.TaskPool.full" title="Permalink to this definition">¶</a></dt>
  118. <dd><p>Is the pool full?</p>
  119. <table class="docutils field-list" frame="void" rules="none">
  120. <col class="field-name" />
  121. <col class="field-body" />
  122. <tbody valign="top">
  123. <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 processes
  124. has been reached.</td>
  125. </tr>
  126. </tbody>
  127. </table>
  128. </dd></dl>
  129. <dl class="method">
  130. <dt id="celery.pool.TaskPool.get_worker_pids">
  131. <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>
  132. <dd>Returns the process id&#8217;s of all the pool workers.</dd></dl>
  133. <dl class="method">
  134. <dt id="celery.pool.TaskPool.on_ready">
  135. <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>
  136. <dd>What to do when a worker task is ready and its return value has
  137. been collected.</dd></dl>
  138. <dl class="method">
  139. <dt id="celery.pool.TaskPool.on_return">
  140. <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>
  141. <dd>What to do when the process returns.</dd></dl>
  142. <dl class="method">
  143. <dt id="celery.pool.TaskPool.reap">
  144. <tt class="descname">reap</tt><big>(</big><big>)</big><a class="headerlink" href="#celery.pool.TaskPool.reap" title="Permalink to this definition">¶</a></dt>
  145. <dd>Reap finished tasks.</dd></dl>
  146. <dl class="method">
  147. <dt id="celery.pool.TaskPool.run">
  148. <tt class="descname">run</tt><big>(</big><big>)</big><a class="headerlink" href="#celery.pool.TaskPool.run" title="Permalink to this definition">¶</a></dt>
  149. <dd><p>Run the task pool.</p>
  150. <p>Will pre-fork all workers so they&#8217;re ready to accept tasks.</p>
  151. </dd></dl>
  152. <dl class="method">
  153. <dt id="celery.pool.TaskPool.terminate">
  154. <tt class="descname">terminate</tt><big>(</big><big>)</big><a class="headerlink" href="#celery.pool.TaskPool.terminate" title="Permalink to this definition">¶</a></dt>
  155. <dd>Terminate the pool.</dd></dl>
  156. <dl class="method">
  157. <dt id="celery.pool.TaskPool.wait_for_result">
  158. <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>
  159. <dd><p>Waits for the first process in the pool to finish.</p>
  160. <p>This operation is blocking.</p>
  161. </dd></dl>
  162. </dd></dl>
  163. </div>
  164. </div>
  165. </div>
  166. </div>
  167. <div class="sphinxsidebar">
  168. <div class="sphinxsidebarwrapper">
  169. <h4>Previous topic</h4>
  170. <p class="topless"><a href="celery.worker.html"
  171. title="previous chapter">Multiprocessing Worker - celery.worker</a></p>
  172. <h4>Next topic</h4>
  173. <p class="topless"><a href="celery.backends.html"
  174. title="next chapter">Backends - celery.backends</a></p>
  175. <h3>This Page</h3>
  176. <ul class="this-page-menu">
  177. <li><a href="../sources/reference/celery.pool.txt"
  178. rel="nofollow">Show Source</a></li>
  179. </ul>
  180. <div id="searchbox" style="display: none">
  181. <h3>Quick search</h3>
  182. <form class="search" action="../search.html" method="get">
  183. <input type="text" name="q" size="18" />
  184. <input type="submit" value="Go" />
  185. <input type="hidden" name="check_keywords" value="yes" />
  186. <input type="hidden" name="area" value="default" />
  187. </form>
  188. <p class="searchtip" style="font-size: 90%">
  189. Enter search terms or a module, class or function name.
  190. </p>
  191. </div>
  192. <script type="text/javascript">$('#searchbox').show(0);</script>
  193. </div>
  194. </div>
  195. <div class="clearer"></div>
  196. </div>
  197. <div class="related">
  198. <h3>Navigation</h3>
  199. <ul>
  200. <li class="right" style="margin-right: 10px">
  201. <a href="../genindex.html" title="General Index"
  202. >index</a></li>
  203. <li class="right" >
  204. <a href="../modindex.html" title="Global Module Index"
  205. >modules</a> |</li>
  206. <li class="right" >
  207. <a href="celery.backends.html" title="Backends - celery.backends"
  208. >next</a> |</li>
  209. <li class="right" >
  210. <a href="celery.worker.html" title="Multiprocessing Worker - celery.worker"
  211. >previous</a> |</li>
  212. <li><a href="../index.html">Celery v0.3.12 (unstable) documentation</a> &raquo;</li>
  213. <li><a href="index.html" >Module API Reference</a> &raquo;</li>
  214. </ul>
  215. </div>
  216. <div class="footer">
  217. &copy; Copyright 2009, Ask Solem.
  218. Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 0.6.1.
  219. </div>
  220. </body>
  221. </html>