| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196 | <!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>Worker Controller Threads - celery.worker.controllers — Celery v0.7.0 (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.7.0 (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.7.0 (unstable) documentation" href="../index.html" />    <link rel="up" title="Module API Reference" href="index.html" />    <link rel="next" title="Task Pool - celery.pool" href="celery.pool.html" />    <link rel="prev" title="Executable Jobs - celery.worker.job" href="celery.worker.job.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.pool.html" title="Task Pool - celery.pool"             accesskey="N">next</a> |</li>        <li class="right" >          <a href="celery.worker.job.html" title="Executable Jobs - celery.worker.job"             accesskey="P">previous</a> |</li>        <li><a href="../index.html">Celery v0.7.0 (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.worker.controllers"><h1>Worker Controller Threads - celery.worker.controllers<a class="headerlink" href="#module-celery.worker.controllers" title="Permalink to this headline">¶</a></h1><p>Worker Controller Threads</p><dl class="class"><dt id="celery.worker.controllers.BackgroundThread"><em class="property">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><dd><p>Thread running an infinite loop which for every iterationcalls 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><p>This also implements graceful shutdown of the thread by providingthe <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><dl class="method"><dt id="celery.worker.controllers.BackgroundThread.on_iteration"><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><dd>This is the method called for every iteration and must beimplemented 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><dl class="method"><dt id="celery.worker.controllers.BackgroundThread.on_start"><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><dd>This handler is run at thread start, just before the infiniteloop.</dd></dl><dl class="method"><dt id="celery.worker.controllers.BackgroundThread.on_stop"><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><dd>This handler is run when the thread is shutdown.</dd></dl><dl class="method"><dt id="celery.worker.controllers.BackgroundThread.run"><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><dd><p>This is the body of the thread.</p><p>To start the thread use <tt class="xref docutils literal"><span class="pre">start()</span></tt> instead.</p></dd></dl><dl class="method"><dt id="celery.worker.controllers.BackgroundThread.stop"><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><dd>Gracefully shutdown the thread.</dd></dl></dd></dl><dl class="class"><dt id="celery.worker.controllers.Mediator"><em class="property">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><dd><p>Thread continuously sending tasks in the queue to the pool.</p><dl class="attribute"><dt id="celery.worker.controllers.Mediator.bucket_queue"><tt class="descname">bucket_queue</tt><a class="headerlink" href="#celery.worker.controllers.Mediator.bucket_queue" title="Permalink to this definition">¶</a></dt><dd>The task queue, a <tt class="xref docutils literal"><span class="pre">Queue.Queue</span></tt> instance.</dd></dl><dl class="attribute"><dt id="celery.worker.controllers.Mediator.callback"><tt class="descname">callback</tt><a class="headerlink" href="#celery.worker.controllers.Mediator.callback" title="Permalink to this definition">¶</a></dt><dd>The callback used to process tasks retrieved from the<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></dd></dl><dl class="class"><dt id="celery.worker.controllers.PeriodicWorkController"><em class="property">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><dd><p>A thread that continuously checks if there are<tt class="xref docutils literal"><span class="pre">celery.task.PeriodicTask</span></tt> tasks waiting for execution,and executes them. It also finds tasks in the hold queue that isready for execution and moves them to the bucket queue.</p><p>(Tasks in the hold queue are tasks waiting for retry, or with an<tt class="docutils literal"><span class="pre">eta</span></tt>/<tt class="docutils literal"><span class="pre">countdown</span></tt>.)</p><dl class="method"><dt id="celery.worker.controllers.PeriodicWorkController.on_start"><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><dd>Do backend-specific periodic task initialization.</dd></dl><dl class="method"><dt id="celery.worker.controllers.PeriodicWorkController.process_hold_queue"><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><dd>Finds paused tasks that are ready for execution and movethem to the <tt class="xref docutils literal"><span class="pre">bucket_queue</span></tt>.</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.job.html"                                  title="previous chapter">Executable Jobs - celery.worker.job</a></p>            <h4>Next topic</h4>            <p class="topless"><a href="celery.pool.html"                                  title="next chapter">Task Pool - celery.pool</a></p>            <h3>This Page</h3>            <ul class="this-page-menu">              <li><a href="../sources/reference/celery.worker.controllers.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.pool.html" title="Task Pool - celery.pool"             >next</a> |</li>        <li class="right" >          <a href="celery.worker.job.html" title="Executable Jobs - celery.worker.job"             >previous</a> |</li>        <li><a href="../index.html">Celery v0.7.0 (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.2.    </div>  </body></html>
 |