celery.worker.controllers.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  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>Worker Controller Threads - celery.worker.controllers &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="Task Pool - celery.pool" href="celery.pool.html" />
  23. <link rel="prev" title="Executable Jobs - celery.worker.job" href="celery.worker.job.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.pool.html" title="Task Pool - celery.pool"
  37. accesskey="N">next</a> |</li>
  38. <li class="right" >
  39. <a href="celery.worker.job.html" title="Executable Jobs - celery.worker.job"
  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.worker.controllers">
  50. <h1>Worker Controller Threads - celery.worker.controllers<a class="headerlink" href="#module-celery.worker.controllers" title="Permalink to this headline">¶</a></h1>
  51. <p>Worker Controller Threads</p>
  52. <dl class="class">
  53. <dt id="celery.worker.controllers.BackgroundThread">
  54. <em class="property">
  55. class </em><tt class="descclassname">celery.worker.controllers.</tt><tt class="descname">BackgroundThread</tt><a class="headerlink" href="#celery.worker.controllers.BackgroundThread" title="Permalink to this definition">¶</a></dt>
  56. <dd><p>Thread running an infinite loop which for every iteration
  57. calls its <a title="celery.worker.controllers.BackgroundThread.on_iteration" class="reference internal" href="#celery.worker.controllers.BackgroundThread.on_iteration"><tt class="xref docutils literal"><span class="pre">on_iteration()</span></tt></a> method.</p>
  58. <p>This also implements graceful shutdown of the thread by providing
  59. the <a title="celery.worker.controllers.BackgroundThread.stop" class="reference internal" href="#celery.worker.controllers.BackgroundThread.stop"><tt class="xref docutils literal"><span class="pre">stop()</span></tt></a> method.</p>
  60. <dl class="method">
  61. <dt id="celery.worker.controllers.BackgroundThread.on_iteration">
  62. <tt class="descname">on_iteration</tt><big>(</big><big>)</big><a class="headerlink" href="#celery.worker.controllers.BackgroundThread.on_iteration" title="Permalink to this definition">¶</a></dt>
  63. <dd>This is the method called for every iteration and must be
  64. implemented by every subclass of <a title="celery.worker.controllers.BackgroundThread" class="reference internal" href="#celery.worker.controllers.BackgroundThread"><tt class="xref docutils literal"><span class="pre">BackgroundThread</span></tt></a>.</dd></dl>
  65. <dl class="method">
  66. <dt id="celery.worker.controllers.BackgroundThread.on_start">
  67. <tt class="descname">on_start</tt><big>(</big><big>)</big><a class="headerlink" href="#celery.worker.controllers.BackgroundThread.on_start" title="Permalink to this definition">¶</a></dt>
  68. <dd>This handler is run at thread start, just before the infinite
  69. loop.</dd></dl>
  70. <dl class="method">
  71. <dt id="celery.worker.controllers.BackgroundThread.on_stop">
  72. <tt class="descname">on_stop</tt><big>(</big><big>)</big><a class="headerlink" href="#celery.worker.controllers.BackgroundThread.on_stop" title="Permalink to this definition">¶</a></dt>
  73. <dd>This handler is run when the thread is shutdown.</dd></dl>
  74. <dl class="method">
  75. <dt id="celery.worker.controllers.BackgroundThread.run">
  76. <tt class="descname">run</tt><big>(</big><big>)</big><a class="headerlink" href="#celery.worker.controllers.BackgroundThread.run" title="Permalink to this definition">¶</a></dt>
  77. <dd><p>This is the body of the thread.</p>
  78. <p>To start the thread use <tt class="xref docutils literal"><span class="pre">start()</span></tt> instead.</p>
  79. </dd></dl>
  80. <dl class="method">
  81. <dt id="celery.worker.controllers.BackgroundThread.stop">
  82. <tt class="descname">stop</tt><big>(</big><big>)</big><a class="headerlink" href="#celery.worker.controllers.BackgroundThread.stop" title="Permalink to this definition">¶</a></dt>
  83. <dd>Gracefully shutdown the thread.</dd></dl>
  84. </dd></dl>
  85. <dl class="class">
  86. <dt id="celery.worker.controllers.Mediator">
  87. <em class="property">
  88. class </em><tt class="descclassname">celery.worker.controllers.</tt><tt class="descname">Mediator</tt><big>(</big><em>bucket_queue</em>, <em>callback</em><big>)</big><a class="headerlink" href="#celery.worker.controllers.Mediator" title="Permalink to this definition">¶</a></dt>
  89. <dd><p>Thread continuously sending tasks in the queue to the pool.</p>
  90. <dl class="attribute">
  91. <dt id="celery.worker.controllers.Mediator.bucket_queue">
  92. <tt class="descname">bucket_queue</tt><a class="headerlink" href="#celery.worker.controllers.Mediator.bucket_queue" title="Permalink to this definition">¶</a></dt>
  93. <dd>The task queue, a <tt class="xref docutils literal"><span class="pre">Queue.Queue</span></tt> instance.</dd></dl>
  94. <dl class="attribute">
  95. <dt id="celery.worker.controllers.Mediator.callback">
  96. <tt class="descname">callback</tt><a class="headerlink" href="#celery.worker.controllers.Mediator.callback" title="Permalink to this definition">¶</a></dt>
  97. <dd>The callback used to process tasks retrieved from the
  98. <a title="celery.worker.controllers.Mediator.bucket_queue" class="reference internal" href="#celery.worker.controllers.Mediator.bucket_queue"><tt class="xref docutils literal"><span class="pre">bucket_queue</span></tt></a>.</dd></dl>
  99. </dd></dl>
  100. <dl class="class">
  101. <dt id="celery.worker.controllers.PeriodicWorkController">
  102. <em class="property">
  103. class </em><tt class="descclassname">celery.worker.controllers.</tt><tt class="descname">PeriodicWorkController</tt><big>(</big><em>bucket_queue</em>, <em>hold_queue</em><big>)</big><a class="headerlink" href="#celery.worker.controllers.PeriodicWorkController" title="Permalink to this definition">¶</a></dt>
  104. <dd><p>A thread that continuously checks if there are
  105. <tt class="xref docutils literal"><span class="pre">celery.task.PeriodicTask</span></tt> tasks waiting for execution,
  106. and executes them. It also finds tasks in the hold queue that is
  107. ready for execution and moves them to the bucket queue.</p>
  108. <p>(Tasks in the hold queue are tasks waiting for retry, or with an
  109. <tt class="docutils literal"><span class="pre">eta</span></tt>/<tt class="docutils literal"><span class="pre">countdown</span></tt>.)</p>
  110. <dl class="method">
  111. <dt id="celery.worker.controllers.PeriodicWorkController.on_start">
  112. <tt class="descname">on_start</tt><big>(</big><big>)</big><a class="headerlink" href="#celery.worker.controllers.PeriodicWorkController.on_start" title="Permalink to this definition">¶</a></dt>
  113. <dd>Do backend-specific periodic task initialization.</dd></dl>
  114. <dl class="method">
  115. <dt id="celery.worker.controllers.PeriodicWorkController.process_hold_queue">
  116. <tt class="descname">process_hold_queue</tt><big>(</big><big>)</big><a class="headerlink" href="#celery.worker.controllers.PeriodicWorkController.process_hold_queue" title="Permalink to this definition">¶</a></dt>
  117. <dd>Finds paused tasks that are ready for execution and move
  118. them to the <tt class="xref docutils literal"><span class="pre">bucket_queue</span></tt>.</dd></dl>
  119. </dd></dl>
  120. </div>
  121. </div>
  122. </div>
  123. </div>
  124. <div class="sphinxsidebar">
  125. <div class="sphinxsidebarwrapper">
  126. <h4>Previous topic</h4>
  127. <p class="topless"><a href="celery.worker.job.html"
  128. title="previous chapter">Executable Jobs - celery.worker.job</a></p>
  129. <h4>Next topic</h4>
  130. <p class="topless"><a href="celery.pool.html"
  131. title="next chapter">Task Pool - celery.pool</a></p>
  132. <h3>This Page</h3>
  133. <ul class="this-page-menu">
  134. <li><a href="../sources/reference/celery.worker.controllers.txt"
  135. rel="nofollow">Show Source</a></li>
  136. </ul>
  137. <div id="searchbox" style="display: none">
  138. <h3>Quick search</h3>
  139. <form class="search" action="../search.html" method="get">
  140. <input type="text" name="q" size="18" />
  141. <input type="submit" value="Go" />
  142. <input type="hidden" name="check_keywords" value="yes" />
  143. <input type="hidden" name="area" value="default" />
  144. </form>
  145. <p class="searchtip" style="font-size: 90%">
  146. Enter search terms or a module, class or function name.
  147. </p>
  148. </div>
  149. <script type="text/javascript">$('#searchbox').show(0);</script>
  150. </div>
  151. </div>
  152. <div class="clearer"></div>
  153. </div>
  154. <div class="related">
  155. <h3>Navigation</h3>
  156. <ul>
  157. <li class="right" style="margin-right: 10px">
  158. <a href="../genindex.html" title="General Index"
  159. >index</a></li>
  160. <li class="right" >
  161. <a href="../modindex.html" title="Global Module Index"
  162. >modules</a> |</li>
  163. <li class="right" >
  164. <a href="celery.pool.html" title="Task Pool - celery.pool"
  165. >next</a> |</li>
  166. <li class="right" >
  167. <a href="celery.worker.job.html" title="Executable Jobs - celery.worker.job"
  168. >previous</a> |</li>
  169. <li><a href="../index.html">Celery v0.7.0 (unstable) documentation</a> &raquo;</li>
  170. <li><a href="index.html" >Module API Reference</a> &raquo;</li>
  171. </ul>
  172. </div>
  173. <div class="footer">
  174. &copy; Copyright 2009, Ask Solem.
  175. Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 0.6.2.
  176. </div>
  177. </body>
  178. </html>