123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322 |
- <!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>Multiprocessing Worker - celery.worker — Celery v0.1.15 documentation</title>
- <link rel="stylesheet" href="../static/default.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.1.15',
- 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.1.15 documentation" href="../index.html" />
- <link rel="next" title="Backends - celery.backends" href="celery.backends.html" />
- <link rel="prev" title="Task Discovery - celery.discovery" href="celery.discovery.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.discovery.html" title="Task Discovery - celery.discovery"
- accesskey="P">previous</a> |</li>
- <li><a href="../index.html">Celery v0.1.15 documentation</a> »</li>
- </ul>
- </div>
- <div class="document">
- <div class="documentwrapper">
- <div class="bodywrapper">
- <div class="body">
-
- <div class="section" id="module-celery.worker">
- <h1>Multiprocessing Worker - celery.worker<a class="headerlink" href="#module-celery.worker" title="Permalink to this headline">¶</a></h1>
- <p>celery.worker</p>
- <dl class="exception">
- <dt id="celery.worker.EmptyQueue">
- <em class="property">
- exception </em><tt class="descclassname">celery.worker.</tt><tt class="descname">EmptyQueue</tt><a class="headerlink" href="#celery.worker.EmptyQueue" title="Permalink to this definition">¶</a></dt>
- <dd>The message queue is currently empty.</dd></dl>
- <dl class="class">
- <dt id="celery.worker.TaskDaemon">
- <em class="property">
- class </em><tt class="descclassname">celery.worker.</tt><tt class="descname">TaskDaemon</tt><big>(</big><em>concurrency=None</em>, <em>logfile=None</em>, <em>loglevel=None</em>, <em>queue_wakeup_after=None</em><big>)</big><a class="headerlink" href="#celery.worker.TaskDaemon" title="Permalink to this definition">¶</a></dt>
- <dd><p>Executes tasks waiting in the task queue.</p>
- <dl class="attribute">
- <dt id="celery.worker.TaskDaemon.concurrency">
- <tt class="descname">concurrency</tt><a class="headerlink" href="#celery.worker.TaskDaemon.concurrency" title="Permalink to this definition">¶</a></dt>
- <dd>The number of simultaneous processes doing work (default:
- <tt class="docutils literal"><span class="pre">celery.conf.DAEMON_CONCURRENCY</span></tt>)</dd></dl>
- <dl class="attribute">
- <dt id="celery.worker.TaskDaemon.loglevel">
- <tt class="descname">loglevel</tt><a class="headerlink" href="#celery.worker.TaskDaemon.loglevel" title="Permalink to this definition">¶</a></dt>
- <dd>The loglevel used (default: <tt class="docutils literal"><span class="pre">logging.INFO</span></tt>)</dd></dl>
- <dl class="attribute">
- <dt id="celery.worker.TaskDaemon.logfile">
- <tt class="descname">logfile</tt><a class="headerlink" href="#celery.worker.TaskDaemon.logfile" title="Permalink to this definition">¶</a></dt>
- <dd>The logfile used, if no logfile is specified it uses <tt class="docutils literal"><span class="pre">stderr</span></tt>
- (default: <tt class="docutils literal"><span class="pre">celery.conf.DAEMON_LOG_FILE</span></tt>).</dd></dl>
- <dl class="attribute">
- <dt id="celery.worker.TaskDaemon.queue_wakeup_after">
- <tt class="descname">queue_wakeup_after</tt><a class="headerlink" href="#celery.worker.TaskDaemon.queue_wakeup_after" title="Permalink to this definition">¶</a></dt>
- <dd>The time it takes for the daemon to wake up after the queue is empty,
- so it can check for more work
- (default: <tt class="docutils literal"><span class="pre">celery.conf.QUEUE_WAKEUP_AFTER</span></tt>).</dd></dl>
- <dl class="attribute">
- <dt id="celery.worker.TaskDaemon.empty_msg_emit_every">
- <tt class="descname">empty_msg_emit_every</tt><a class="headerlink" href="#celery.worker.TaskDaemon.empty_msg_emit_every" title="Permalink to this definition">¶</a></dt>
- <dd>How often the daemon emits the <tt class="docutils literal"><span class="pre">Waiting</span> <span class="pre">for</span> <span class="pre">queue</span></tt> message.
- If this is <tt class="xref docutils literal"><span class="pre">None</span></tt>, the message will never be logged.
- (default: <tt class="docutils literal"><span class="pre">celery.conf.EMPTY_MSG_EMIT_EVERY</span></tt>)</dd></dl>
- <dl class="attribute">
- <dt id="celery.worker.TaskDaemon.logger">
- <tt class="descname">logger</tt><a class="headerlink" href="#celery.worker.TaskDaemon.logger" title="Permalink to this definition">¶</a></dt>
- <dd>The <tt class="xref docutils literal"><span class="pre">logging.Logger</span></tt> instance used for logging.</dd></dl>
- <dl class="attribute">
- <dt id="celery.worker.TaskDaemon.pool">
- <tt class="descname">pool</tt><a class="headerlink" href="#celery.worker.TaskDaemon.pool" title="Permalink to this definition">¶</a></dt>
- <dd>The <tt class="xref docutils literal"><span class="pre">multiprocessing.Pool</span></tt> instance used.</dd></dl>
- <dl class="attribute">
- <dt id="celery.worker.TaskDaemon.task_consumer">
- <tt class="descname">task_consumer</tt><a class="headerlink" href="#celery.worker.TaskDaemon.task_consumer" title="Permalink to this definition">¶</a></dt>
- <dd>The <a title="celery.messaging.TaskConsumer" class="reference external" href="celery.messaging.html#celery.messaging.TaskConsumer"><tt class="xref docutils literal"><span class="pre">celery.messaging.TaskConsumer</span></tt></a> instance used.</dd></dl>
- <dl class="method">
- <dt id="celery.worker.TaskDaemon.connection_diagnostics">
- <tt class="descname">connection_diagnostics</tt><big>(</big><big>)</big><a class="headerlink" href="#celery.worker.TaskDaemon.connection_diagnostics" title="Permalink to this definition">¶</a></dt>
- <dd>Diagnose the AMQP connection, and reset if necessary.</dd></dl>
- <dl class="method">
- <dt id="celery.worker.TaskDaemon.execute_next_task">
- <tt class="descname">execute_next_task</tt><big>(</big><big>)</big><a class="headerlink" href="#celery.worker.TaskDaemon.execute_next_task" title="Permalink to this definition">¶</a></dt>
- <dd><p>Execute the next task on the queue using the multiprocessing
- pool.</p>
- <p>Catches all exceptions and logs them with level <tt class="docutils literal"><span class="pre">logging.CRITICAL</span></tt>.</p>
- </dd></dl>
- <dl class="method">
- <dt id="celery.worker.TaskDaemon.fetch_next_task">
- <tt class="descname">fetch_next_task</tt><big>(</big><big>)</big><a class="headerlink" href="#celery.worker.TaskDaemon.fetch_next_task" title="Permalink to this definition">¶</a></dt>
- <dd><p>Fetch the next task from the AMQP broker.</p>
- <p>Raises <a title="celery.worker.EmptyQueue" class="reference internal" href="#celery.worker.EmptyQueue"><tt class="xref docutils literal"><span class="pre">EmptyQueue</span></tt></a> exception if there is no messages
- waiting on the queue.</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">Return type:</th><td class="field-body"><a title="celery.worker.TaskWrapper" class="reference internal" href="#celery.worker.TaskWrapper"><tt class="xref docutils literal"><span class="pre">TaskWrapper</span></tt></a> instance.</td>
- </tr>
- </tbody>
- </table>
- </dd></dl>
- <dl class="method">
- <dt id="celery.worker.TaskDaemon.receive_message">
- <tt class="descname">receive_message</tt><big>(</big><big>)</big><a class="headerlink" href="#celery.worker.TaskDaemon.receive_message" title="Permalink to this definition">¶</a></dt>
- <dd><p>Receive the next message from the Task consumer queue.</p>
- <p>Tries to reset the AMQP connection if not available.
- Returns <tt class="xref docutils literal"><span class="pre">None</span></tt> if no message is waiting on the queue.</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">Return type:</th><td class="field-body"><tt class="xref docutils literal"><span class="pre">carrot.messaging.Message</span></tt> instance.</td>
- </tr>
- </tbody>
- </table>
- </dd></dl>
- <dl class="method">
- <dt id="celery.worker.TaskDaemon.receive_message_cc">
- <tt class="descname">receive_message_cc</tt><big>(</big><big>)</big><a class="headerlink" href="#celery.worker.TaskDaemon.receive_message_cc" title="Permalink to this definition">¶</a></dt>
- <dd>UNUSED.</dd></dl>
- <dl class="method">
- <dt id="celery.worker.TaskDaemon.reset_connection">
- <tt class="descname">reset_connection</tt><big>(</big><big>)</big><a class="headerlink" href="#celery.worker.TaskDaemon.reset_connection" title="Permalink to this definition">¶</a></dt>
- <dd>Reset the AMQP connection, and reinitialize the
- <a title="celery.messaging.TaskConsumer" class="reference external" href="celery.messaging.html#celery.messaging.TaskConsumer"><tt class="xref docutils literal"><span class="pre">celery.messaging.TaskConsumer</span></tt></a> instance.</dd></dl>
- <dl class="method">
- <dt id="celery.worker.TaskDaemon.run">
- <tt class="descname">run</tt><big>(</big><big>)</big><a class="headerlink" href="#celery.worker.TaskDaemon.run" title="Permalink to this definition">¶</a></dt>
- <dd>The worker server’s main loop.</dd></dl>
- <dl class="method">
- <dt id="celery.worker.TaskDaemon.run_periodic_tasks">
- <tt class="descname">run_periodic_tasks</tt><big>(</big><big>)</big><a class="headerlink" href="#celery.worker.TaskDaemon.run_periodic_tasks" title="Permalink to this definition">¶</a></dt>
- <dd><p>Schedule all waiting periodic tasks for execution.</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">Return type:</th><td class="field-body">list of <tt class="xref docutils literal"><span class="pre">celery.models.PeriodicTaskMeta</span></tt> objects.</td>
- </tr>
- </tbody>
- </table>
- </dd></dl>
- <dl class="method">
- <dt id="celery.worker.TaskDaemon.schedule_retry_tasks">
- <tt class="descname">schedule_retry_tasks</tt><big>(</big><big>)</big><a class="headerlink" href="#celery.worker.TaskDaemon.schedule_retry_tasks" title="Permalink to this definition">¶</a></dt>
- <dd>Reschedule all requeued tasks waiting for retry.</dd></dl>
- </dd></dl>
- <dl class="class">
- <dt id="celery.worker.TaskWrapper">
- <em class="property">
- class </em><tt class="descclassname">celery.worker.</tt><tt class="descname">TaskWrapper</tt><big>(</big><em>task_name</em>, <em>task_id</em>, <em>task_func</em>, <em>args</em>, <em>kwargs</em><big>)</big><a class="headerlink" href="#celery.worker.TaskWrapper" title="Permalink to this definition">¶</a></dt>
- <dd><p>Class defining a task to be run.</p>
- <dl class="method">
- <dt id="celery.worker.TaskWrapper.execute">
- <tt class="descname">execute</tt><big>(</big><em>loglevel</em>, <em>logfile</em><big>)</big><a class="headerlink" href="#celery.worker.TaskWrapper.execute" title="Permalink to this definition">¶</a></dt>
- <dd>Execute the task in a <tt class="docutils literal"><span class="pre">jail()</span></tt> and store its result and status
- in the task meta backend.</dd></dl>
- <dl class="method">
- <dt id="celery.worker.TaskWrapper.execute_using_pool">
- <tt class="descname">execute_using_pool</tt><big>(</big><em>pool</em>, <em>loglevel</em>, <em>logfile</em><big>)</big><a class="headerlink" href="#celery.worker.TaskWrapper.execute_using_pool" title="Permalink to this definition">¶</a></dt>
- <dd><p>Like <tt class="docutils literal"><span class="pre">execute</span></tt>, but using the <tt class="docutils literal"><span class="pre">multiprocessing</span></tt> pool.</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">Return type:</th><td class="field-body"><tt class="xref docutils literal"><span class="pre">multiprocessing.AsyncResult</span></tt> instance.</td>
- </tr>
- </tbody>
- </table>
- </dd></dl>
- <dl class="method">
- <dt id="celery.worker.TaskWrapper.extend_kwargs_with_logging">
- <tt class="descname">extend_kwargs_with_logging</tt><big>(</big><em>loglevel</em>, <em>logfile</em><big>)</big><a class="headerlink" href="#celery.worker.TaskWrapper.extend_kwargs_with_logging" title="Permalink to this definition">¶</a></dt>
- <dd><p>Extend the tasks keyword arguments with standard task arguments.</p>
- <p>These are <tt class="docutils literal"><span class="pre">logfile</span></tt>, <tt class="docutils literal"><span class="pre">loglevel</span></tt>, <tt class="docutils literal"><span class="pre">task_id</span></tt> and <tt class="docutils literal"><span class="pre">task_name</span></tt>.</p>
- </dd></dl>
- <dl class="classmethod">
- <dt id="celery.worker.TaskWrapper.from_message">
- <em class="property">
- classmethod </em><tt class="descname">from_message</tt><big>(</big><em>message</em><big>)</big><a class="headerlink" href="#celery.worker.TaskWrapper.from_message" title="Permalink to this definition">¶</a></dt>
- <dd><p>Create a TaskWrapper from a message returned by
- <a title="celery.messaging.TaskConsumer" class="reference external" href="celery.messaging.html#celery.messaging.TaskConsumer"><tt class="xref docutils literal"><span class="pre">celery.messaging.TaskConsumer</span></tt></a>.</p>
- <p>If the message is not a proper task it raises
- <a title="celery.worker.UnknownTask" class="reference internal" href="#celery.worker.UnknownTask"><tt class="xref docutils literal"><span class="pre">UnknownTask</span></tt></a> exception.</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">Return type:</th><td class="field-body"><a title="celery.worker.TaskWrapper" class="reference internal" href="#celery.worker.TaskWrapper"><tt class="xref docutils literal"><span class="pre">TaskWrapper</span></tt></a> instance.</td>
- </tr>
- </tbody>
- </table>
- </dd></dl>
- </dd></dl>
- <dl class="exception">
- <dt id="celery.worker.UnknownTask">
- <em class="property">
- exception </em><tt class="descclassname">celery.worker.</tt><tt class="descname">UnknownTask</tt><a class="headerlink" href="#celery.worker.UnknownTask" title="Permalink to this definition">¶</a></dt>
- <dd>Got an unknown task in the queue. The message is requeued and
- ignored.</dd></dl>
- <dl class="function">
- <dt id="celery.worker.jail">
- <tt class="descclassname">celery.worker.</tt><tt class="descname">jail</tt><big>(</big><em>task_id</em>, <em>callable_</em>, <em>args</em>, <em>kwargs</em><big>)</big><a class="headerlink" href="#celery.worker.jail" title="Permalink to this definition">¶</a></dt>
- <dd><p>Wraps the task in a jail which saves the status and result
- of the task execution to the task meta backend.</p>
- <p>If the call results in an exception, it saves the exception as the task
- result, and sets the task status to <tt class="docutils literal"><span class="pre">FAILURE</span></tt>.</p>
- <p>If the call was successful, it saves the result to the task result
- backend, and sets the task status to <tt class="docutils literal"><span class="pre">DONE</span></tt>.</p>
- </dd></dl>
- </div>
- </div>
- </div>
- </div>
- <div class="sphinxsidebar">
- <div class="sphinxsidebarwrapper">
- <h4>Previous topic</h4>
- <p class="topless"><a href="celery.discovery.html"
- title="previous chapter">Task Discovery - celery.discovery</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.worker.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.discovery.html" title="Task Discovery - celery.discovery"
- >previous</a> |</li>
- <li><a href="../index.html">Celery v0.1.15 documentation</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>
|