celery.worker.html 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416
  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>Multiprocessing Worker - celery.worker &mdash; Celery v0.2.0-pre3 documentation</title>
  7. <link rel="stylesheet" href="../static/default.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.2.0-pre3',
  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.2.0-pre3 documentation" href="../index.html" />
  21. <link rel="next" title="Backends - celery.backends" href="celery.backends.html" />
  22. <link rel="prev" title="Task Discovery - celery.discovery" href="celery.discovery.html" />
  23. </head>
  24. <body>
  25. <div class="related">
  26. <h3>Navigation</h3>
  27. <ul>
  28. <li class="right" style="margin-right: 10px">
  29. <a href="../genindex.html" title="General Index"
  30. accesskey="I">index</a></li>
  31. <li class="right" >
  32. <a href="../modindex.html" title="Global Module Index"
  33. accesskey="M">modules</a> |</li>
  34. <li class="right" >
  35. <a href="celery.backends.html" title="Backends - celery.backends"
  36. accesskey="N">next</a> |</li>
  37. <li class="right" >
  38. <a href="celery.discovery.html" title="Task Discovery - celery.discovery"
  39. accesskey="P">previous</a> |</li>
  40. <li><a href="../index.html">Celery v0.2.0-pre3 documentation</a> &raquo;</li>
  41. </ul>
  42. </div>
  43. <div class="document">
  44. <div class="documentwrapper">
  45. <div class="bodywrapper">
  46. <div class="body">
  47. <div class="section" id="module-celery.worker">
  48. <h1>Multiprocessing Worker - celery.worker<a class="headerlink" href="#module-celery.worker" title="Permalink to this headline">¶</a></h1>
  49. <p>celery.worker</p>
  50. <dl class="exception">
  51. <dt id="celery.worker.EmptyQueue">
  52. <em class="property">
  53. 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>
  54. <dd>The message queue is currently empty.</dd></dl>
  55. <dl class="class">
  56. <dt id="celery.worker.TaskDaemon">
  57. <em class="property">
  58. 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>
  59. <dd><p>Executes tasks waiting in the task queue.</p>
  60. <table class="docutils field-list" frame="void" rules="none">
  61. <col class="field-name" />
  62. <col class="field-body" />
  63. <tbody valign="top">
  64. <tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
  65. <li><em>concurrency</em> &#8211; see <a title="celery.worker.TaskDaemon.concurrency" class="reference internal" href="#celery.worker.TaskDaemon.concurrency"><tt class="xref docutils literal"><span class="pre">concurrency</span></tt></a>.</li>
  66. <li><em>logfile</em> &#8211; see <a title="celery.worker.TaskDaemon.logfile" class="reference internal" href="#celery.worker.TaskDaemon.logfile"><tt class="xref docutils literal"><span class="pre">logfile</span></tt></a>.</li>
  67. <li><em>loglevel</em> &#8211; see <a title="celery.worker.TaskDaemon.loglevel" class="reference internal" href="#celery.worker.TaskDaemon.loglevel"><tt class="xref docutils literal"><span class="pre">loglevel</span></tt></a>.</li>
  68. <li><em>queue_wakeup_after</em> &#8211; see <a title="celery.worker.TaskDaemon.queue_wakeup_after" class="reference internal" href="#celery.worker.TaskDaemon.queue_wakeup_after"><tt class="xref docutils literal"><span class="pre">queue_wakeup_after</span></tt></a>.</li>
  69. </ul>
  70. </td>
  71. </tr>
  72. </tbody>
  73. </table>
  74. <dl class="attribute">
  75. <dt id="celery.worker.TaskDaemon.concurrency">
  76. <tt class="descname">concurrency</tt><a class="headerlink" href="#celery.worker.TaskDaemon.concurrency" title="Permalink to this definition">¶</a></dt>
  77. <dd>The number of simultaneous processes doing work (default:
  78. <a title="celery.conf.DAEMON_CONCURRENCY" class="reference external" href="celery.conf.html#celery.conf.DAEMON_CONCURRENCY"><tt class="xref docutils literal"><span class="pre">celery.conf.DAEMON_CONCURRENCY</span></tt></a>)</dd></dl>
  79. <dl class="attribute">
  80. <dt id="celery.worker.TaskDaemon.loglevel">
  81. <tt class="descname">loglevel</tt><a class="headerlink" href="#celery.worker.TaskDaemon.loglevel" title="Permalink to this definition">¶</a></dt>
  82. <dd>The loglevel used (default: <tt class="xref docutils literal"><span class="pre">logging.INFO</span></tt>)</dd></dl>
  83. <dl class="attribute">
  84. <dt id="celery.worker.TaskDaemon.logfile">
  85. <tt class="descname">logfile</tt><a class="headerlink" href="#celery.worker.TaskDaemon.logfile" title="Permalink to this definition">¶</a></dt>
  86. <dd>The logfile used, if no logfile is specified it uses <tt class="docutils literal"><span class="pre">stderr</span></tt>
  87. (default: <a title="celery.conf.DAEMON_LOG_FILE" class="reference external" href="celery.conf.html#celery.conf.DAEMON_LOG_FILE"><tt class="xref docutils literal"><span class="pre">celery.conf.DAEMON_LOG_FILE</span></tt></a>).</dd></dl>
  88. <dl class="attribute">
  89. <dt id="celery.worker.TaskDaemon.queue_wakeup_after">
  90. <tt class="descname">queue_wakeup_after</tt><a class="headerlink" href="#celery.worker.TaskDaemon.queue_wakeup_after" title="Permalink to this definition">¶</a></dt>
  91. <dd>The time it takes for the daemon to wake up after the queue is empty,
  92. so it can check for more work
  93. (default: <a title="celery.conf.QUEUE_WAKEUP_AFTER" class="reference external" href="celery.conf.html#celery.conf.QUEUE_WAKEUP_AFTER"><tt class="xref docutils literal"><span class="pre">celery.conf.QUEUE_WAKEUP_AFTER</span></tt></a>).</dd></dl>
  94. <dl class="attribute">
  95. <dt id="celery.worker.TaskDaemon.empty_msg_emit_every">
  96. <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>
  97. <dd>How often the daemon emits the <tt class="docutils literal"><span class="pre">&quot;Waiting</span> <span class="pre">for</span> <span class="pre">queue...&quot;</span></tt> message.
  98. If this is <tt class="xref docutils literal"><span class="pre">None</span></tt>, the message will never be logged.
  99. (default: <a title="celery.conf.EMPTY_MSG_EMIT_EVERY" class="reference external" href="celery.conf.html#celery.conf.EMPTY_MSG_EMIT_EVERY"><tt class="xref docutils literal"><span class="pre">celery.conf.EMPTY_MSG_EMIT_EVERY</span></tt></a>)</dd></dl>
  100. <dl class="attribute">
  101. <dt id="celery.worker.TaskDaemon.logger">
  102. <tt class="descname">logger</tt><a class="headerlink" href="#celery.worker.TaskDaemon.logger" title="Permalink to this definition">¶</a></dt>
  103. <dd>The <tt class="xref docutils literal"><span class="pre">logging.Logger</span></tt> instance used for logging.</dd></dl>
  104. <dl class="attribute">
  105. <dt id="celery.worker.TaskDaemon.pool">
  106. <tt class="descname">pool</tt><a class="headerlink" href="#celery.worker.TaskDaemon.pool" title="Permalink to this definition">¶</a></dt>
  107. <dd>The <tt class="xref docutils literal"><span class="pre">multiprocessing.Pool</span></tt> instance used.</dd></dl>
  108. <dl class="attribute">
  109. <dt id="celery.worker.TaskDaemon.task_consumer">
  110. <tt class="descname">task_consumer</tt><a class="headerlink" href="#celery.worker.TaskDaemon.task_consumer" title="Permalink to this definition">¶</a></dt>
  111. <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>
  112. <dl class="method">
  113. <dt id="celery.worker.TaskDaemon.connection_diagnostics">
  114. <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>
  115. <dd>Diagnose the AMQP connection, and reset connection if
  116. necessary.</dd></dl>
  117. <dl class="method">
  118. <dt id="celery.worker.TaskDaemon.execute_next_task">
  119. <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>
  120. <dd><p>Execute the next task on the queue using the multiprocessing pool.</p>
  121. <p>Catches all exceptions and logs them with level
  122. <tt class="xref docutils literal"><span class="pre">logging.CRITICAL</span></tt>.</p>
  123. </dd></dl>
  124. <dl class="method">
  125. <dt id="celery.worker.TaskDaemon.fetch_next_task">
  126. <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>
  127. <dd><p>Fetch the next task from the AMQP broker.</p>
  128. <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 message
  129. waiting on the queue.</p>
  130. <table class="docutils field-list" frame="void" rules="none">
  131. <col class="field-name" />
  132. <col class="field-body" />
  133. <tbody valign="top">
  134. <tr class="field"><th class="field-name">Returns:</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>
  135. </tr>
  136. </tbody>
  137. </table>
  138. </dd></dl>
  139. <dl class="method">
  140. <dt id="celery.worker.TaskDaemon.receive_message">
  141. <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>
  142. <dd><p>Receive the next message from the message broker.</p>
  143. <p>Tries to reset the AMQP connection if not available.
  144. Returns <tt class="xref docutils literal"><span class="pre">None</span></tt> if no message is waiting on the queue.</p>
  145. <table class="docutils field-list" frame="void" rules="none">
  146. <col class="field-name" />
  147. <col class="field-body" />
  148. <tbody valign="top">
  149. <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>
  150. </tr>
  151. </tbody>
  152. </table>
  153. </dd></dl>
  154. <dl class="method">
  155. <dt id="celery.worker.TaskDaemon.reset_connection">
  156. <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>
  157. <dd><p>Reset the AMQP connection, and reinitialize the
  158. <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.</p>
  159. <p>Resets the task consumer in <a title="celery.worker.TaskDaemon.task_consumer" class="reference internal" href="#celery.worker.TaskDaemon.task_consumer"><tt class="xref docutils literal"><span class="pre">task_consumer</span></tt></a>.</p>
  160. </dd></dl>
  161. <dl class="method">
  162. <dt id="celery.worker.TaskDaemon.run">
  163. <tt class="descname">run</tt><big>(</big><big>)</big><a class="headerlink" href="#celery.worker.TaskDaemon.run" title="Permalink to this definition">¶</a></dt>
  164. <dd>Starts the workers main loop.</dd></dl>
  165. <dl class="method">
  166. <dt id="celery.worker.TaskDaemon.run_periodic_tasks">
  167. <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>
  168. <dd><p>Schedule all waiting periodic tasks for execution.</p>
  169. <table class="docutils field-list" frame="void" rules="none">
  170. <col class="field-name" />
  171. <col class="field-body" />
  172. <tbody valign="top">
  173. <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>
  174. </tr>
  175. </tbody>
  176. </table>
  177. </dd></dl>
  178. <dl class="method">
  179. <dt id="celery.worker.TaskDaemon.schedule_retry_tasks">
  180. <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>
  181. <dd>Reschedule all requeued tasks waiting for retry.</dd></dl>
  182. </dd></dl>
  183. <dl class="class">
  184. <dt id="celery.worker.TaskWrapper">
  185. <em class="property">
  186. 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>
  187. <dd><p>Class wrapping a task to be run.</p>
  188. <table class="docutils field-list" frame="void" rules="none">
  189. <col class="field-name" />
  190. <col class="field-body" />
  191. <tbody valign="top">
  192. <tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
  193. <li><em>task_name</em> &#8211; see <a title="celery.worker.TaskWrapper.task_name" class="reference internal" href="#celery.worker.TaskWrapper.task_name"><tt class="xref docutils literal"><span class="pre">task_name</span></tt></a>.</li>
  194. <li><em>task_id</em> &#8211; see <a title="celery.worker.TaskWrapper.task_id" class="reference internal" href="#celery.worker.TaskWrapper.task_id"><tt class="xref docutils literal"><span class="pre">task_id</span></tt></a>.</li>
  195. <li><em>task_func</em> &#8211; see <a title="celery.worker.TaskWrapper.task_func" class="reference internal" href="#celery.worker.TaskWrapper.task_func"><tt class="xref docutils literal"><span class="pre">task_func</span></tt></a></li>
  196. <li><em>args</em> &#8211; see <a title="celery.worker.TaskWrapper.args" class="reference internal" href="#celery.worker.TaskWrapper.args"><tt class="xref docutils literal"><span class="pre">args</span></tt></a></li>
  197. <li><em>kwargs</em> &#8211; see <a title="celery.worker.TaskWrapper.kwargs" class="reference internal" href="#celery.worker.TaskWrapper.kwargs"><tt class="xref docutils literal"><span class="pre">kwargs</span></tt></a>.</li>
  198. </ul>
  199. </td>
  200. </tr>
  201. </tbody>
  202. </table>
  203. <dl class="attribute">
  204. <dt id="celery.worker.TaskWrapper.task_name">
  205. <tt class="descname">task_name</tt><a class="headerlink" href="#celery.worker.TaskWrapper.task_name" title="Permalink to this definition">¶</a></dt>
  206. <dd>Kind of task. Must be a name registered in the task registry.</dd></dl>
  207. <dl class="attribute">
  208. <dt id="celery.worker.TaskWrapper.task_id">
  209. <tt class="descname">task_id</tt><a class="headerlink" href="#celery.worker.TaskWrapper.task_id" title="Permalink to this definition">¶</a></dt>
  210. <dd>UUID of the task.</dd></dl>
  211. <dl class="attribute">
  212. <dt id="celery.worker.TaskWrapper.task_func">
  213. <tt class="descname">task_func</tt><a class="headerlink" href="#celery.worker.TaskWrapper.task_func" title="Permalink to this definition">¶</a></dt>
  214. <dd>The tasks callable object.</dd></dl>
  215. <dl class="attribute">
  216. <dt id="celery.worker.TaskWrapper.args">
  217. <tt class="descname">args</tt><a class="headerlink" href="#celery.worker.TaskWrapper.args" title="Permalink to this definition">¶</a></dt>
  218. <dd>List of positional arguments to apply to the task.</dd></dl>
  219. <dl class="attribute">
  220. <dt id="celery.worker.TaskWrapper.kwargs">
  221. <tt class="descname">kwargs</tt><a class="headerlink" href="#celery.worker.TaskWrapper.kwargs" title="Permalink to this definition">¶</a></dt>
  222. <dd>Mapping of keyword arguments to apply to the task.</dd></dl>
  223. <dl class="method">
  224. <dt id="celery.worker.TaskWrapper.execute">
  225. <tt class="descname">execute</tt><big>(</big><em>loglevel=None</em>, <em>logfile=None</em><big>)</big><a class="headerlink" href="#celery.worker.TaskWrapper.execute" title="Permalink to this definition">¶</a></dt>
  226. <dd><p>Execute the task in a <a title="celery.worker.jail" class="reference internal" href="#celery.worker.jail"><tt class="xref docutils literal"><span class="pre">jail()</span></tt></a> and store return value
  227. and status in the task meta backend.</p>
  228. <table class="docutils field-list" frame="void" rules="none">
  229. <col class="field-name" />
  230. <col class="field-body" />
  231. <tbody valign="top">
  232. <tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
  233. <li><em>loglevel</em> &#8211; The loglevel used by the task.</li>
  234. <li><em>logfile</em> &#8211; The logfile used by the task.</li>
  235. </ul>
  236. </td>
  237. </tr>
  238. </tbody>
  239. </table>
  240. </dd></dl>
  241. <dl class="method">
  242. <dt id="celery.worker.TaskWrapper.execute_using_pool">
  243. <tt class="descname">execute_using_pool</tt><big>(</big><em>pool</em>, <em>loglevel=None</em>, <em>logfile=None</em><big>)</big><a class="headerlink" href="#celery.worker.TaskWrapper.execute_using_pool" title="Permalink to this definition">¶</a></dt>
  244. <dd><p>Like <a title="celery.worker.TaskWrapper.execute" class="reference internal" href="#celery.worker.TaskWrapper.execute"><tt class="xref docutils literal"><span class="pre">execute()</span></tt></a>, but using the <tt class="xref docutils literal"><span class="pre">multiprocessing</span></tt> pool.</p>
  245. <table class="docutils field-list" frame="void" rules="none">
  246. <col class="field-name" />
  247. <col class="field-body" />
  248. <tbody valign="top">
  249. <tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
  250. <li><em>pool</em> &#8211; A <a href="#id1"><span class="problematic" id="id2">:cls:`multiprocessing.Pool`</span></a> instance.</li>
  251. <li><em>loglevel</em> &#8211; The loglevel used by the task.</li>
  252. <li><em>logfile</em> &#8211; The logfile used by the task.</li>
  253. </ul>
  254. </td>
  255. </tr>
  256. </tbody>
  257. </table>
  258. <p>:returns <tt class="xref docutils literal"><span class="pre">multiprocessing.AsyncResult</span></tt> instance.</p>
  259. </dd></dl>
  260. <dl class="method">
  261. <dt id="celery.worker.TaskWrapper.extend_with_default_kwargs">
  262. <tt class="descname">extend_with_default_kwargs</tt><big>(</big><em>loglevel</em>, <em>logfile</em><big>)</big><a class="headerlink" href="#celery.worker.TaskWrapper.extend_with_default_kwargs" title="Permalink to this definition">¶</a></dt>
  263. <dd><p>Extend the tasks keyword arguments with standard task arguments.</p>
  264. <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>
  265. </dd></dl>
  266. <dl class="classmethod">
  267. <dt id="celery.worker.TaskWrapper.from_message">
  268. <em class="property">
  269. 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>
  270. <dd><p>Create a <a title="celery.worker.TaskWrapper" class="reference internal" href="#celery.worker.TaskWrapper"><tt class="xref docutils literal"><span class="pre">TaskWrapper</span></tt></a> from a task message sent by
  271. <a title="celery.messaging.TaskPublisher" class="reference external" href="celery.messaging.html#celery.messaging.TaskPublisher"><tt class="xref docutils literal"><span class="pre">celery.messaging.TaskPublisher</span></tt></a>.</p>
  272. <table class="docutils field-list" frame="void" rules="none">
  273. <col class="field-name" />
  274. <col class="field-body" />
  275. <tbody valign="top">
  276. <tr class="field"><th class="field-name" colspan="2">Raises <a title="celery.worker.UnknownTask" class="reference internal" href="#celery.worker.UnknownTask">UnknownTask</a>:</th></tr>
  277. <tr><td>&nbsp;</td><td class="field-body">if the message does not describe a task,
  278. the message is also rejected.</td>
  279. </tr>
  280. <tr class="field"><th class="field-name">Returns:</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>
  281. </tr>
  282. </tbody>
  283. </table>
  284. </dd></dl>
  285. </dd></dl>
  286. <dl class="exception">
  287. <dt id="celery.worker.UnknownTask">
  288. <em class="property">
  289. 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>
  290. <dd>Got an unknown task in the queue. The message is requeued and
  291. ignored.</dd></dl>
  292. <dl class="function">
  293. <dt id="celery.worker.jail">
  294. <tt class="descclassname">celery.worker.</tt><tt class="descname">jail</tt><big>(</big><em>task_id</em>, <em>func</em>, <em>args</em>, <em>kwargs</em><big>)</big><a class="headerlink" href="#celery.worker.jail" title="Permalink to this definition">¶</a></dt>
  295. <dd><p>Wraps the task in a jail, which catches all exceptions, and
  296. saves the status and result of the task execution to the task
  297. meta backend.</p>
  298. <p>If the call was successful, it saves the result to the task result
  299. backend, and sets the task status to <tt class="docutils literal"><span class="pre">&quot;DONE&quot;</span></tt>.</p>
  300. <p>If the call results in an exception, it saves the exception as the task
  301. result, and sets the task status to <tt class="docutils literal"><span class="pre">&quot;FAILURE&quot;</span></tt>.</p>
  302. <table class="docutils field-list" frame="void" rules="none">
  303. <col class="field-name" />
  304. <col class="field-body" />
  305. <tbody valign="top">
  306. <tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  307. <li><em>task_id</em> &#8211; The id of the task.</li>
  308. <li><em>func</em> &#8211; Callable object to execute.</li>
  309. <li><em>args</em> &#8211; List of positional args to pass on to the function.</li>
  310. <li><em>kwargs</em> &#8211; Keyword arguments mapping to pass on to the function.</li>
  311. </ul>
  312. </td>
  313. </tr>
  314. <tr class="field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">the function return value on success.</p>
  315. </td>
  316. </tr>
  317. <tr class="field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">the exception instance on failure.</p>
  318. </td>
  319. </tr>
  320. </tbody>
  321. </table>
  322. </dd></dl>
  323. </div>
  324. </div>
  325. </div>
  326. </div>
  327. <div class="sphinxsidebar">
  328. <div class="sphinxsidebarwrapper">
  329. <h4>Previous topic</h4>
  330. <p class="topless"><a href="celery.discovery.html"
  331. title="previous chapter">Task Discovery - celery.discovery</a></p>
  332. <h4>Next topic</h4>
  333. <p class="topless"><a href="celery.backends.html"
  334. title="next chapter">Backends - celery.backends</a></p>
  335. <h3>This Page</h3>
  336. <ul class="this-page-menu">
  337. <li><a href="../sources/reference/celery.worker.txt"
  338. rel="nofollow">Show Source</a></li>
  339. </ul>
  340. <div id="searchbox" style="display: none">
  341. <h3>Quick search</h3>
  342. <form class="search" action="../search.html" method="get">
  343. <input type="text" name="q" size="18" />
  344. <input type="submit" value="Go" />
  345. <input type="hidden" name="check_keywords" value="yes" />
  346. <input type="hidden" name="area" value="default" />
  347. </form>
  348. <p class="searchtip" style="font-size: 90%">
  349. Enter search terms or a module, class or function name.
  350. </p>
  351. </div>
  352. <script type="text/javascript">$('#searchbox').show(0);</script>
  353. </div>
  354. </div>
  355. <div class="clearer"></div>
  356. </div>
  357. <div class="related">
  358. <h3>Navigation</h3>
  359. <ul>
  360. <li class="right" style="margin-right: 10px">
  361. <a href="../genindex.html" title="General Index"
  362. >index</a></li>
  363. <li class="right" >
  364. <a href="../modindex.html" title="Global Module Index"
  365. >modules</a> |</li>
  366. <li class="right" >
  367. <a href="celery.backends.html" title="Backends - celery.backends"
  368. >next</a> |</li>
  369. <li class="right" >
  370. <a href="celery.discovery.html" title="Task Discovery - celery.discovery"
  371. >previous</a> |</li>
  372. <li><a href="../index.html">Celery v0.2.0-pre3 documentation</a> &raquo;</li>
  373. </ul>
  374. </div>
  375. <div class="footer">
  376. &copy; Copyright 2009, Ask Solem.
  377. Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 0.6.1.
  378. </div>
  379. </body>
  380. </html>