celery.pool.html 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  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.7.0 (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.7.0 (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.7.0 (unstable) documentation" href="../index.html" />
  21. <link rel="up" title="Module API Reference" href="index.html" />
  22. <link rel="next" title="Process Supervisor - celery.supervisor" href="celery.supervisor.html" />
  23. <link rel="prev" title="Worker Controller Threads - celery.worker.controllers" href="celery.worker.controllers.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.supervisor.html" title="Process Supervisor - celery.supervisor"
  37. accesskey="N">next</a> |</li>
  38. <li class="right" >
  39. <a href="celery.worker.controllers.html" title="Worker Controller Threads - celery.worker.controllers"
  40. accesskey="P">previous</a> |</li>
  41. <li><a href="../index.html">Celery v0.7.0 (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.DynamicPool">
  54. <em class="property">
  55. class </em><tt class="descclassname">celery.pool.</tt><tt class="descname">DynamicPool</tt><big>(</big><em>processes=None</em>, <em>initializer=None</em>, <em>initargs=()</em><big>)</big><a class="headerlink" href="#celery.pool.DynamicPool" title="Permalink to this definition">¶</a></dt>
  56. <dd><p>Version of <tt class="xref docutils literal"><span class="pre">multiprocessing.Pool</span></tt> that can dynamically grow
  57. in size.</p>
  58. <dl class="method">
  59. <dt id="celery.pool.DynamicPool.add_worker">
  60. <tt class="descname">add_worker</tt><big>(</big><big>)</big><a class="headerlink" href="#celery.pool.DynamicPool.add_worker" title="Permalink to this definition">¶</a></dt>
  61. <dd>Add another worker to the pool.</dd></dl>
  62. <dl class="method">
  63. <dt id="celery.pool.DynamicPool.grow">
  64. <tt class="descname">grow</tt><big>(</big><em>size=1</em><big>)</big><a class="headerlink" href="#celery.pool.DynamicPool.grow" title="Permalink to this definition">¶</a></dt>
  65. <dd><p>Add workers to the pool.</p>
  66. <table class="docutils field-list" frame="void" rules="none">
  67. <col class="field-name" />
  68. <col class="field-body" />
  69. <tbody valign="top">
  70. <tr class="field"><th class="field-name">Parameter:</th><td class="field-body"><em>size</em> &#8211; Number of workers to add (default: 1)</td>
  71. </tr>
  72. </tbody>
  73. </table>
  74. </dd></dl>
  75. <dl class="method">
  76. <dt id="celery.pool.DynamicPool.replace_dead_workers">
  77. <tt class="descname">replace_dead_workers</tt><big>(</big><big>)</big><a class="headerlink" href="#celery.pool.DynamicPool.replace_dead_workers" title="Permalink to this definition">¶</a></dt>
  78. <dd><p>Replace dead workers in the pool by spawning new ones.</p>
  79. <table class="docutils field-list" frame="void" rules="none">
  80. <col class="field-name" />
  81. <col class="field-body" />
  82. <tbody valign="top">
  83. <tr class="field"><th class="field-name">Returns:</th><td class="field-body">number of dead processes replaced, or <tt class="xref docutils literal"><span class="pre">None</span></tt> if all
  84. processes are alive and running.</td>
  85. </tr>
  86. </tbody>
  87. </table>
  88. </dd></dl>
  89. </dd></dl>
  90. <dl class="class">
  91. <dt id="celery.pool.TaskPool">
  92. <em class="property">
  93. 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>
  94. <dd><p>Process Pool for processing tasks in parallel.</p>
  95. <table class="docutils field-list" frame="void" rules="none">
  96. <col class="field-name" />
  97. <col class="field-body" />
  98. <tbody valign="top">
  99. <tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
  100. <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>
  101. <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>
  102. </ul>
  103. </td>
  104. </tr>
  105. </tbody>
  106. </table>
  107. <dl class="attribute">
  108. <dt id="celery.pool.TaskPool.limit">
  109. <tt class="descname">limit</tt><a class="headerlink" href="#celery.pool.TaskPool.limit" title="Permalink to this definition">¶</a></dt>
  110. <dd>The number of processes that can run simultaneously.</dd></dl>
  111. <dl class="attribute">
  112. <dt id="celery.pool.TaskPool.logger">
  113. <tt class="descname">logger</tt><a class="headerlink" href="#celery.pool.TaskPool.logger" title="Permalink to this definition">¶</a></dt>
  114. <dd>The logger used for debugging.</dd></dl>
  115. <dl class="method">
  116. <dt id="celery.pool.TaskPool.apply_async">
  117. <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_ack=&lt;function &lt;lambda&gt; at 0x21a7c70&gt;</em><big>)</big><a class="headerlink" href="#celery.pool.TaskPool.apply_async" title="Permalink to this definition">¶</a></dt>
  118. <dd><p>Equivalent of the :func:<tt class="docutils literal"><span class="pre">apply</span></tt> built-in function.</p>
  119. <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
  120. otherwise the thread which handles the result will get blocked.</p>
  121. </dd></dl>
  122. <dl class="method">
  123. <dt id="celery.pool.TaskPool.on_ready">
  124. <tt class="descname">on_ready</tt><big>(</big><em>callbacks</em>, <em>errbacks</em>, <em>on_ack</em>, <em>ret_value</em><big>)</big><a class="headerlink" href="#celery.pool.TaskPool.on_ready" title="Permalink to this definition">¶</a></dt>
  125. <dd>What to do when a worker task is ready and its return value has
  126. been collected.</dd></dl>
  127. <dl class="method">
  128. <dt id="celery.pool.TaskPool.start">
  129. <tt class="descname">start</tt><big>(</big><big>)</big><a class="headerlink" href="#celery.pool.TaskPool.start" title="Permalink to this definition">¶</a></dt>
  130. <dd><p>Run the task pool.</p>
  131. <p>Will pre-fork all workers so they&#8217;re ready to accept tasks.</p>
  132. </dd></dl>
  133. <dl class="method">
  134. <dt id="celery.pool.TaskPool.stop">
  135. <tt class="descname">stop</tt><big>(</big><big>)</big><a class="headerlink" href="#celery.pool.TaskPool.stop" title="Permalink to this definition">¶</a></dt>
  136. <dd>Terminate the pool.</dd></dl>
  137. </dd></dl>
  138. <dl class="function">
  139. <dt id="celery.pool.pid_is_dead">
  140. <tt class="descclassname">celery.pool.</tt><tt class="descname">pid_is_dead</tt><big>(</big><em>pid</em><big>)</big><a class="headerlink" href="#celery.pool.pid_is_dead" title="Permalink to this definition">¶</a></dt>
  141. <dd><p>Check if a process is not running by PID.</p>
  142. <table class="docutils field-list" frame="void" rules="none">
  143. <col class="field-name" />
  144. <col class="field-body" />
  145. <tbody valign="top">
  146. <tr class="field"><th class="field-name">Rtype bool:</th><td class="field-body"></td>
  147. </tr>
  148. </tbody>
  149. </table>
  150. </dd></dl>
  151. <dl class="function">
  152. <dt id="celery.pool.process_is_dead">
  153. <tt class="descclassname">celery.pool.</tt><tt class="descname">process_is_dead</tt><big>(</big><em>process</em><big>)</big><a class="headerlink" href="#celery.pool.process_is_dead" title="Permalink to this definition">¶</a></dt>
  154. <dd><p>Check if process is not running anymore.</p>
  155. <p>First it finds out if the process is running by sending
  156. signal 0. Then if the process is a child process, and is running
  157. it finds out if it&#8217;s a zombie process and reaps it.
  158. If the process is running and is not a zombie it tries to send
  159. a ping through the process pipe.</p>
  160. <table class="docutils field-list" frame="void" rules="none">
  161. <col class="field-name" />
  162. <col class="field-body" />
  163. <tbody valign="top">
  164. <tr class="field"><th class="field-name">Parameter:</th><td class="field-body"><em>process</em> &#8211; A <tt class="xref docutils literal"><span class="pre">multiprocessing.Process</span></tt> instance.</td>
  165. </tr>
  166. <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 process is not running, <tt class="xref docutils literal"><span class="pre">False</span></tt> otherwise.</td>
  167. </tr>
  168. </tbody>
  169. </table>
  170. </dd></dl>
  171. <dl class="function">
  172. <dt id="celery.pool.reap_process">
  173. <tt class="descclassname">celery.pool.</tt><tt class="descname">reap_process</tt><big>(</big><em>pid</em><big>)</big><a class="headerlink" href="#celery.pool.reap_process" title="Permalink to this definition">¶</a></dt>
  174. <dd><p>Reap process if the process is a zombie.</p>
  175. <table class="docutils field-list" frame="void" rules="none">
  176. <col class="field-name" />
  177. <col class="field-body" />
  178. <tbody valign="top">
  179. <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 process was reaped or is not running,
  180. <tt class="xref docutils literal"><span class="pre">False</span></tt> otherwise.</td>
  181. </tr>
  182. </tbody>
  183. </table>
  184. </dd></dl>
  185. </div>
  186. </div>
  187. </div>
  188. </div>
  189. <div class="sphinxsidebar">
  190. <div class="sphinxsidebarwrapper">
  191. <h4>Previous topic</h4>
  192. <p class="topless"><a href="celery.worker.controllers.html"
  193. title="previous chapter">Worker Controller Threads - celery.worker.controllers</a></p>
  194. <h4>Next topic</h4>
  195. <p class="topless"><a href="celery.supervisor.html"
  196. title="next chapter">Process Supervisor - celery.supervisor</a></p>
  197. <h3>This Page</h3>
  198. <ul class="this-page-menu">
  199. <li><a href="../sources/reference/celery.pool.txt"
  200. rel="nofollow">Show Source</a></li>
  201. </ul>
  202. <div id="searchbox" style="display: none">
  203. <h3>Quick search</h3>
  204. <form class="search" action="../search.html" method="get">
  205. <input type="text" name="q" size="18" />
  206. <input type="submit" value="Go" />
  207. <input type="hidden" name="check_keywords" value="yes" />
  208. <input type="hidden" name="area" value="default" />
  209. </form>
  210. <p class="searchtip" style="font-size: 90%">
  211. Enter search terms or a module, class or function name.
  212. </p>
  213. </div>
  214. <script type="text/javascript">$('#searchbox').show(0);</script>
  215. </div>
  216. </div>
  217. <div class="clearer"></div>
  218. </div>
  219. <div class="related">
  220. <h3>Navigation</h3>
  221. <ul>
  222. <li class="right" style="margin-right: 10px">
  223. <a href="../genindex.html" title="General Index"
  224. >index</a></li>
  225. <li class="right" >
  226. <a href="../modindex.html" title="Global Module Index"
  227. >modules</a> |</li>
  228. <li class="right" >
  229. <a href="celery.supervisor.html" title="Process Supervisor - celery.supervisor"
  230. >next</a> |</li>
  231. <li class="right" >
  232. <a href="celery.worker.controllers.html" title="Worker Controller Threads - celery.worker.controllers"
  233. >previous</a> |</li>
  234. <li><a href="../index.html">Celery v0.7.0 (unstable) documentation</a> &raquo;</li>
  235. <li><a href="index.html" >Module API Reference</a> &raquo;</li>
  236. </ul>
  237. </div>
  238. <div class="footer">
  239. &copy; Copyright 2009, Ask Solem.
  240. Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 0.6.2.
  241. </div>
  242. </body>
  243. </html>