celery.task.html 49 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725
  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>Tasks - celery.task &mdash; Celery v0.3.5 (unstable) documentation</title>
  7. <link rel="stylesheet" href="../static/agogo.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.3.5 (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.3.5 (unstable) documentation" href="../index.html" />
  21. <link rel="up" title="Module API Reference" href="index.html" />
  22. <link rel="next" title="Task Result - celery.result" href="celery.result.html" />
  23. <link rel="prev" title="Module API Reference" href="index.html" />
  24. </head>
  25. <body>
  26. <div class="header-wrapper">
  27. <div class="header">
  28. <h1><a href="../index.html">Celery v0.3.5 (unstable) documentation</a></h1>
  29. <div class="rel">
  30. <a href="../genindex.html" title="General Index"
  31. accesskey="I">index</a> |
  32. <a href="../modindex.html" title="Global Module Index"
  33. accesskey="M">modules</a> |
  34. <a href="celery.result.html" title="Task Result - celery.result"
  35. accesskey="N">next</a> |
  36. <a href="index.html" title="Module API Reference"
  37. accesskey="P">previous</a>
  38. </div>
  39. </div>
  40. </div>
  41. <div class="content-wrapper">
  42. <div class="content">
  43. <div class="document">
  44. <div class="documentwrapper">
  45. <div class="bodywrapper">
  46. <div class="body">
  47. <div class="section" id="module-celery.task">
  48. <h1>Tasks - celery.task<a class="headerlink" href="#module-celery.task" title="Permalink to this headline">¶</a></h1>
  49. <p>Working with tasks and task sets.</p>
  50. <dl class="class">
  51. <dt id="celery.task.AsynchronousMapTask">
  52. <em class="property">
  53. class </em><tt class="descclassname">celery.task.</tt><tt class="descname">AsynchronousMapTask</tt><a class="headerlink" href="#celery.task.AsynchronousMapTask" title="Permalink to this definition">¶</a></dt>
  54. <dd><p>Task used internally by <a title="celery.task.dmap_async" class="reference internal" href="#celery.task.dmap_async"><tt class="xref docutils literal"><span class="pre">dmap_async()</span></tt></a> and
  55. <a title="celery.task.TaskSet.map_async" class="reference internal" href="#celery.task.TaskSet.map_async"><tt class="xref docutils literal"><span class="pre">TaskSet.map_async()</span></tt></a>.</p>
  56. <dl class="method">
  57. <dt id="celery.task.AsynchronousMapTask.run">
  58. <tt class="descname">run</tt><big>(</big><em>serfunc</em>, <em>args</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#celery.task.AsynchronousMapTask.run" title="Permalink to this definition">¶</a></dt>
  59. <dd>The method run by <tt class="docutils literal"><span class="pre">celeryd</span></tt>.</dd></dl>
  60. </dd></dl>
  61. <dl class="class">
  62. <dt id="celery.task.DeleteExpiredTaskMetaTask">
  63. <em class="property">
  64. class </em><tt class="descclassname">celery.task.</tt><tt class="descname">DeleteExpiredTaskMetaTask</tt><a class="headerlink" href="#celery.task.DeleteExpiredTaskMetaTask" title="Permalink to this definition">¶</a></dt>
  65. <dd><p>A periodic task that deletes expired task metadata every day.</p>
  66. <p>This runs the current backend&#8217;s
  67. <a title="celery.backends.base.BaseBackend.cleanup" class="reference external" href="celery.backends.base.html#celery.backends.base.BaseBackend.cleanup"><tt class="xref docutils literal"><span class="pre">celery.backends.base.BaseBackend.cleanup()</span></tt></a> method.</p>
  68. <dl class="method">
  69. <dt id="celery.task.DeleteExpiredTaskMetaTask.run">
  70. <tt class="descname">run</tt><big>(</big><em>**kwargs</em><big>)</big><a class="headerlink" href="#celery.task.DeleteExpiredTaskMetaTask.run" title="Permalink to this definition">¶</a></dt>
  71. <dd>The method run by <tt class="docutils literal"><span class="pre">celeryd</span></tt>.</dd></dl>
  72. </dd></dl>
  73. <dl class="class">
  74. <dt id="celery.task.ExecuteRemoteTask">
  75. <em class="property">
  76. class </em><tt class="descclassname">celery.task.</tt><tt class="descname">ExecuteRemoteTask</tt><a class="headerlink" href="#celery.task.ExecuteRemoteTask" title="Permalink to this definition">¶</a></dt>
  77. <dd><p>Execute an arbitrary function or object.</p>
  78. <p><em>Note</em> You probably want <a title="celery.task.execute_remote" class="reference internal" href="#celery.task.execute_remote"><tt class="xref docutils literal"><span class="pre">execute_remote()</span></tt></a> instead, which this
  79. is an internal component of.</p>
  80. <p>The object must be pickleable, so you can&#8217;t use lambdas or functions
  81. defined in the REPL (that is the python shell, or <tt class="docutils literal"><span class="pre">ipython</span></tt>).</p>
  82. <dl class="method">
  83. <dt id="celery.task.ExecuteRemoteTask.run">
  84. <tt class="descname">run</tt><big>(</big><em>ser_callable</em>, <em>fargs</em>, <em>fkwargs</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#celery.task.ExecuteRemoteTask.run" title="Permalink to this definition">¶</a></dt>
  85. <dd><table class="docutils field-list" frame="void" rules="none">
  86. <col class="field-name" />
  87. <col class="field-body" />
  88. <tbody valign="top">
  89. <tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
  90. <li><em>ser_callable</em> &#8211; A pickled function or callable object.</li>
  91. <li><em>fargs</em> &#8211; Positional arguments to apply to the function.</li>
  92. <li><em>fkwargs</em> &#8211; Keyword arguments to apply to the function.</li>
  93. </ul>
  94. </td>
  95. </tr>
  96. </tbody>
  97. </table>
  98. </dd></dl>
  99. </dd></dl>
  100. <dl class="class">
  101. <dt id="celery.task.PeriodicTask">
  102. <em class="property">
  103. class </em><tt class="descclassname">celery.task.</tt><tt class="descname">PeriodicTask</tt><a class="headerlink" href="#celery.task.PeriodicTask" title="Permalink to this definition">¶</a></dt>
  104. <dd><p>A periodic task is a task that behaves like a <em>cron</em> job.</p>
  105. <dl class="attribute">
  106. <dt id="celery.task.PeriodicTask.run_every">
  107. <tt class="descname">run_every</tt><a class="headerlink" href="#celery.task.PeriodicTask.run_every" title="Permalink to this definition">¶</a></dt>
  108. <dd><em>REQUIRED</em> Defines how often the task is run (its interval),
  109. it can be either a <tt class="xref docutils literal"><span class="pre">datetime.timedelta</span></tt> object or an
  110. integer specifying the time in seconds.</dd></dl>
  111. <table class="docutils field-list" frame="void" rules="none">
  112. <col class="field-name" />
  113. <col class="field-body" />
  114. <tbody valign="top">
  115. <tr class="field"><th class="field-name" colspan="2">Raises NotImplementedError:</th></tr>
  116. <tr><td>&nbsp;</td><td class="field-body">if the <a title="celery.task.PeriodicTask.run_every" class="reference internal" href="#celery.task.PeriodicTask.run_every"><tt class="xref docutils literal"><span class="pre">run_every</span></tt></a> attribute is
  117. not defined.</td>
  118. </tr>
  119. </tbody>
  120. </table>
  121. <p>You have to register the periodic task in the task registry.</p>
  122. <p>Example</p>
  123. <div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">celery.task</span> <span class="kn">import</span> <span class="n">tasks</span><span class="p">,</span> <span class="n">PeriodicTask</span>
  124. <span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">datetime</span> <span class="kn">import</span> <span class="n">timedelta</span>
  125. <span class="gp">&gt;&gt;&gt; </span><span class="k">class</span> <span class="nc">MyPeriodicTask</span><span class="p">(</span><span class="n">PeriodicTask</span><span class="p">):</span>
  126. <span class="gp">... </span> <span class="n">name</span> <span class="o">=</span> <span class="s">&quot;my_periodic_task&quot;</span>
  127. <span class="gp">... </span> <span class="n">run_every</span> <span class="o">=</span> <span class="n">timedelta</span><span class="p">(</span><span class="n">seconds</span><span class="o">=</span><span class="mf">30</span><span class="p">)</span>
  128. <span class="gp">...</span>
  129. <span class="gp">... </span> <span class="k">def</span> <span class="nf">run</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
  130. <span class="gp">... </span> <span class="n">logger</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">get_logger</span><span class="p">(</span><span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
  131. <span class="gp">... </span> <span class="n">logger</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s">&quot;Running MyPeriodicTask&quot;</span><span class="p">)</span>
  132. <span class="gp">&gt;&gt;&gt; </span><span class="n">tasks</span><span class="o">.</span><span class="n">register</span><span class="p">(</span><span class="n">MyPeriodicTask</span><span class="p">)</span>
  133. </pre></div>
  134. </div>
  135. </dd></dl>
  136. <dl class="class">
  137. <dt id="celery.task.Task">
  138. <em class="property">
  139. class </em><tt class="descclassname">celery.task.</tt><tt class="descname">Task</tt><a class="headerlink" href="#celery.task.Task" title="Permalink to this definition">¶</a></dt>
  140. <dd><p>A task that can be delayed for execution by the <tt class="docutils literal"><span class="pre">celery</span></tt> daemon.</p>
  141. <p>All subclasses of <a title="celery.task.Task" class="reference internal" href="#celery.task.Task"><tt class="xref docutils literal"><span class="pre">Task</span></tt></a> must define the <a title="celery.task.Task.run" class="reference internal" href="#celery.task.Task.run"><tt class="xref docutils literal"><span class="pre">run()</span></tt></a> method,
  142. which is the actual method the <tt class="docutils literal"><span class="pre">celery</span></tt> daemon executes.</p>
  143. <p>The <a title="celery.task.Task.run" class="reference internal" href="#celery.task.Task.run"><tt class="xref docutils literal"><span class="pre">run()</span></tt></a> method supports both positional, and keyword arguments.</p>
  144. <dl class="attribute">
  145. <dt id="celery.task.Task.name">
  146. <tt class="descname">name</tt><a class="headerlink" href="#celery.task.Task.name" title="Permalink to this definition">¶</a></dt>
  147. <dd><em>REQUIRED</em> All subclasses of <a title="celery.task.Task" class="reference internal" href="#celery.task.Task"><tt class="xref docutils literal"><span class="pre">Task</span></tt></a> has to define the
  148. <a title="celery.task.Task.name" class="reference internal" href="#celery.task.Task.name"><tt class="xref docutils literal"><span class="pre">name</span></tt></a> attribute. This is the name of the task, registered
  149. in the task registry, and passed to <a title="celery.task.delay_task" class="reference internal" href="#celery.task.delay_task"><tt class="xref docutils literal"><span class="pre">delay_task()</span></tt></a>.</dd></dl>
  150. <dl class="attribute">
  151. <dt id="celery.task.Task.type">
  152. <tt class="descname">type</tt><a class="headerlink" href="#celery.task.Task.type" title="Permalink to this definition">¶</a></dt>
  153. <dd>The type of task, currently this can be <tt class="docutils literal"><span class="pre">regular</span></tt>, or <tt class="docutils literal"><span class="pre">periodic</span></tt>,
  154. however if you want a periodic task, you should subclass
  155. <a title="celery.task.PeriodicTask" class="reference internal" href="#celery.task.PeriodicTask"><tt class="xref docutils literal"><span class="pre">PeriodicTask</span></tt></a> instead.</dd></dl>
  156. <table class="docutils field-list" frame="void" rules="none">
  157. <col class="field-name" />
  158. <col class="field-body" />
  159. <tbody valign="top">
  160. <tr class="field"><th class="field-name" colspan="2">Raises NotImplementedError:</th></tr>
  161. <tr><td>&nbsp;</td><td class="field-body">if the <a title="celery.task.Task.name" class="reference internal" href="#celery.task.Task.name"><tt class="xref docutils literal"><span class="pre">name</span></tt></a> attribute is not set.</td>
  162. </tr>
  163. </tbody>
  164. </table>
  165. <p>The resulting class is callable, which if called will apply the
  166. <a title="celery.task.Task.run" class="reference internal" href="#celery.task.Task.run"><tt class="xref docutils literal"><span class="pre">run()</span></tt></a> method.</p>
  167. <p>Examples</p>
  168. <p>This is a simple task just logging a message,</p>
  169. <div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">celery.task</span> <span class="kn">import</span> <span class="n">tasks</span><span class="p">,</span> <span class="n">Task</span>
  170. <span class="gp">&gt;&gt;&gt; </span><span class="k">class</span> <span class="nc">MyTask</span><span class="p">(</span><span class="n">Task</span><span class="p">):</span>
  171. <span class="gp">... </span> <span class="n">name</span> <span class="o">=</span> <span class="s">&quot;mytask&quot;</span>
  172. <span class="gp">...</span>
  173. <span class="gp">... </span> <span class="k">def</span> <span class="nf">run</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">some_arg</span><span class="o">=</span><span class="bp">None</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
  174. <span class="gp">... </span> <span class="n">logger</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">get_logger</span><span class="p">(</span><span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
  175. <span class="gp">... </span> <span class="n">logger</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s">&quot;Running MyTask with arg some_arg=</span><span class="si">%s</span><span class="s">&quot;</span> <span class="o">%</span>
  176. <span class="gp">... </span> <span class="n">some_arg</span><span class="p">))</span>
  177. <span class="gp">... </span> <span class="k">return</span> <span class="mf">42</span>
  178. <span class="gp">... </span><span class="n">tasks</span><span class="o">.</span><span class="n">register</span><span class="p">(</span><span class="n">MyTask</span><span class="p">)</span>
  179. </pre></div>
  180. </div>
  181. <p>You can delay the task using the classmethod <a title="celery.task.Task.delay" class="reference internal" href="#celery.task.Task.delay"><tt class="xref docutils literal"><span class="pre">delay()</span></tt></a>...</p>
  182. <div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">result</span> <span class="o">=</span> <span class="n">MyTask</span><span class="o">.</span><span class="n">delay</span><span class="p">(</span><span class="n">some_arg</span><span class="o">=</span><span class="s">&quot;foo&quot;</span><span class="p">)</span>
  183. <span class="gp">&gt;&gt;&gt; </span><span class="n">result</span><span class="o">.</span><span class="n">status</span> <span class="c"># after some time</span>
  184. <span class="go">&#39;DONE&#39;</span>
  185. <span class="gp">&gt;&gt;&gt; </span><span class="n">result</span><span class="o">.</span><span class="n">result</span>
  186. <span class="go">42</span>
  187. </pre></div>
  188. </div>
  189. <p>...or using the <a title="celery.task.delay_task" class="reference internal" href="#celery.task.delay_task"><tt class="xref docutils literal"><span class="pre">delay_task()</span></tt></a> function, by passing the name of
  190. the task.</p>
  191. <div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">celery.task</span> <span class="kn">import</span> <span class="n">delay_task</span>
  192. <span class="gp">&gt;&gt;&gt; </span><span class="n">result</span> <span class="o">=</span> <span class="n">delay_task</span><span class="p">(</span><span class="n">MyTask</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> <span class="n">some_arg</span><span class="o">=</span><span class="s">&quot;foo&quot;</span><span class="p">)</span>
  193. </pre></div>
  194. </div>
  195. <dl class="classmethod">
  196. <dt id="celery.task.Task.apply_async">
  197. <em class="property">
  198. classmethod </em><tt class="descname">apply_async</tt><big>(</big><em>args=None</em>, <em>kwargs=None</em>, <em>**options</em><big>)</big><a class="headerlink" href="#celery.task.Task.apply_async" title="Permalink to this definition">¶</a></dt>
  199. <dd><p>Delay this task for execution by the <tt class="docutils literal"><span class="pre">celery</span></tt> daemon(s).</p>
  200. <table class="docutils field-list" frame="void" rules="none">
  201. <col class="field-name" />
  202. <col class="field-body" />
  203. <tbody valign="top">
  204. <tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  205. <li><em>args</em> &#8211; positional arguments passed on to the task.</li>
  206. <li><em>kwargs</em> &#8211; keyword arguments passed on to the task.</li>
  207. </ul>
  208. </td>
  209. </tr>
  210. <tr class="field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last"><a title="celery.result.AsyncResult" class="reference external" href="celery.result.html#celery.result.AsyncResult"><tt class="xref docutils literal"><span class="pre">celery.result.AsyncResult</span></tt></a></p>
  211. </td>
  212. </tr>
  213. </tbody>
  214. </table>
  215. <p>See <a title="celery.task.apply_async" class="reference internal" href="#celery.task.apply_async"><tt class="xref docutils literal"><span class="pre">apply_async()</span></tt></a>.</p>
  216. </dd></dl>
  217. <dl class="classmethod">
  218. <dt id="celery.task.Task.delay">
  219. <em class="property">
  220. classmethod </em><tt class="descname">delay</tt><big>(</big><em>*args</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#celery.task.Task.delay" title="Permalink to this definition">¶</a></dt>
  221. <dd><p>Delay this task for execution by the <tt class="docutils literal"><span class="pre">celery</span></tt> daemon(s).</p>
  222. <table class="docutils field-list" frame="void" rules="none">
  223. <col class="field-name" />
  224. <col class="field-body" />
  225. <tbody valign="top">
  226. <tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  227. <li><em>*args</em> &#8211; positional arguments passed on to the task.</li>
  228. <li><em>**kwargs</em> &#8211; keyword arguments passed on to the task.</li>
  229. </ul>
  230. </td>
  231. </tr>
  232. <tr class="field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last"><a title="celery.result.AsyncResult" class="reference external" href="celery.result.html#celery.result.AsyncResult"><tt class="xref docutils literal"><span class="pre">celery.result.AsyncResult</span></tt></a></p>
  233. </td>
  234. </tr>
  235. </tbody>
  236. </table>
  237. <p>See <a title="celery.task.delay_task" class="reference internal" href="#celery.task.delay_task"><tt class="xref docutils literal"><span class="pre">delay_task()</span></tt></a>.</p>
  238. </dd></dl>
  239. <dl class="method">
  240. <dt id="celery.task.Task.get_consumer">
  241. <tt class="descname">get_consumer</tt><big>(</big><big>)</big><a class="headerlink" href="#celery.task.Task.get_consumer" title="Permalink to this definition">¶</a></dt>
  242. <dd><p>Get a celery task message consumer.</p>
  243. <table class="docutils field-list" frame="void" rules="none">
  244. <col class="field-name" />
  245. <col class="field-body" />
  246. <tbody valign="top">
  247. <tr class="field"><th class="field-name">Return type:</th><td class="field-body"><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>.</td>
  248. </tr>
  249. </tbody>
  250. </table>
  251. <p>Please be sure to close the AMQP connection when you&#8217;re done
  252. with this object. i.e.:</p>
  253. <div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">consumer</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">get_consumer</span><span class="p">()</span>
  254. <span class="gp">&gt;&gt;&gt; </span><span class="c"># do something with consumer</span>
  255. <span class="gp">&gt;&gt;&gt; </span><span class="n">consumer</span><span class="o">.</span><span class="n">connection</span><span class="o">.</span><span class="n">close</span><span class="p">()</span>
  256. </pre></div>
  257. </div>
  258. </dd></dl>
  259. <dl class="method">
  260. <dt id="celery.task.Task.get_logger">
  261. <tt class="descname">get_logger</tt><big>(</big><em>**kwargs</em><big>)</big><a class="headerlink" href="#celery.task.Task.get_logger" title="Permalink to this definition">¶</a></dt>
  262. <dd><p>Get process-aware logger object.</p>
  263. <p>See <a title="celery.log.setup_logger" class="reference external" href="celery.log.html#celery.log.setup_logger"><tt class="xref docutils literal"><span class="pre">celery.log.setup_logger()</span></tt></a>.</p>
  264. </dd></dl>
  265. <dl class="method">
  266. <dt id="celery.task.Task.get_publisher">
  267. <tt class="descname">get_publisher</tt><big>(</big><big>)</big><a class="headerlink" href="#celery.task.Task.get_publisher" title="Permalink to this definition">¶</a></dt>
  268. <dd><p>Get a celery task message publisher.</p>
  269. <table class="docutils field-list" frame="void" rules="none">
  270. <col class="field-name" />
  271. <col class="field-body" />
  272. <tbody valign="top">
  273. <tr class="field"><th class="field-name">Return type:</th><td class="field-body"><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>.</td>
  274. </tr>
  275. </tbody>
  276. </table>
  277. <p>Please be sure to close the AMQP connection when you&#8217;re done
  278. with this object, i.e.:</p>
  279. <div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">publisher</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">get_publisher</span><span class="p">()</span>
  280. <span class="gp">&gt;&gt;&gt; </span><span class="c"># do something with publisher</span>
  281. <span class="gp">&gt;&gt;&gt; </span><span class="n">publisher</span><span class="o">.</span><span class="n">connection</span><span class="o">.</span><span class="n">close</span><span class="p">()</span>
  282. </pre></div>
  283. </div>
  284. </dd></dl>
  285. <dl class="method">
  286. <dt id="celery.task.Task.run">
  287. <tt class="descname">run</tt><big>(</big><em>*args</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#celery.task.Task.run" title="Permalink to this definition">¶</a></dt>
  288. <dd><p><em>REQUIRED</em> The actual task.</p>
  289. <p>All subclasses of <a title="celery.task.Task" class="reference internal" href="#celery.task.Task"><tt class="xref docutils literal"><span class="pre">Task</span></tt></a> must define the run method.</p>
  290. <table class="docutils field-list" frame="void" rules="none">
  291. <col class="field-name" />
  292. <col class="field-body" />
  293. <tbody valign="top">
  294. <tr class="field"><th class="field-name" colspan="2">Raises NotImplementedError:</th></tr>
  295. <tr><td>&nbsp;</td><td class="field-body">by default, so you have to override
  296. this method in your subclass.</td>
  297. </tr>
  298. </tbody>
  299. </table>
  300. </dd></dl>
  301. </dd></dl>
  302. <dl class="class">
  303. <dt id="celery.task.TaskSet">
  304. <em class="property">
  305. class </em><tt class="descclassname">celery.task.</tt><tt class="descname">TaskSet</tt><big>(</big><em>task</em>, <em>args</em><big>)</big><a class="headerlink" href="#celery.task.TaskSet" title="Permalink to this definition">¶</a></dt>
  306. <dd><p>A task containing several subtasks, making it possible
  307. to track how many, or when all of the tasks has been completed.</p>
  308. <table class="docutils field-list" frame="void" rules="none">
  309. <col class="field-name" />
  310. <col class="field-body" />
  311. <tbody valign="top">
  312. <tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
  313. <li><em>task</em> &#8211; The task class or name.
  314. Can either be a fully qualified task name, or a task class.</li>
  315. <li><em>args</em> &#8211; A list of args, kwargs pairs.
  316. e.g. <tt class="docutils literal"><span class="pre">[[args1,</span> <span class="pre">kwargs1],</span> <span class="pre">[args2,</span> <span class="pre">kwargs2],</span> <span class="pre">...,</span> <span class="pre">[argsN,</span> <span class="pre">kwargsN]]</span></tt></li>
  317. </ul>
  318. </td>
  319. </tr>
  320. </tbody>
  321. </table>
  322. <dl class="attribute">
  323. <dt id="celery.task.TaskSet.task_name">
  324. <tt class="descname">task_name</tt><a class="headerlink" href="#celery.task.TaskSet.task_name" title="Permalink to this definition">¶</a></dt>
  325. <dd>The name of the task.</dd></dl>
  326. <dl class="attribute">
  327. <dt id="celery.task.TaskSet.arguments">
  328. <tt class="descname">arguments</tt><a class="headerlink" href="#celery.task.TaskSet.arguments" title="Permalink to this definition">¶</a></dt>
  329. <dd>The arguments, as passed to the task set constructor.</dd></dl>
  330. <dl class="attribute">
  331. <dt id="celery.task.TaskSet.total">
  332. <tt class="descname">total</tt><a class="headerlink" href="#celery.task.TaskSet.total" title="Permalink to this definition">¶</a></dt>
  333. <dd>Total number of tasks in this task set.</dd></dl>
  334. <p>Example</p>
  335. <blockquote>
  336. <div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">djangofeeds.tasks</span> <span class="kn">import</span> <span class="n">RefreshFeedTask</span>
  337. <span class="gp">&gt;&gt;&gt; </span><span class="n">taskset</span> <span class="o">=</span> <span class="n">TaskSet</span><span class="p">(</span><span class="n">RefreshFeedTask</span><span class="p">,</span> <span class="n">args</span><span class="o">=</span><span class="p">[</span>
  338. <span class="gp">... </span> <span class="p">[],</span> <span class="p">{</span><span class="s">&quot;feed_url&quot;</span><span class="p">:</span> <span class="s">&quot;http://cnn.com/rss&quot;</span><span class="p">},</span>
  339. <span class="gp">... </span> <span class="p">[],</span> <span class="p">{</span><span class="s">&quot;feed_url&quot;</span><span class="p">:</span> <span class="s">&quot;http://bbc.com/rss&quot;</span><span class="p">},</span>
  340. <span class="gp">... </span> <span class="p">[],</span> <span class="p">{</span><span class="s">&quot;feed_url&quot;</span><span class="p">:</span> <span class="s">&quot;http://xkcd.com/rss&quot;</span><span class="p">}])</span>
  341. </pre></div>
  342. </div>
  343. <div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">taskset_result</span> <span class="o">=</span> <span class="n">taskset</span><span class="o">.</span><span class="n">run</span><span class="p">()</span>
  344. <span class="gp">&gt;&gt;&gt; </span><span class="n">list_of_return_values</span> <span class="o">=</span> <span class="n">taskset</span><span class="o">.</span><span class="n">join</span><span class="p">()</span>
  345. </pre></div>
  346. </div>
  347. </blockquote>
  348. <dl class="method">
  349. <dt id="celery.task.TaskSet.iterate">
  350. <tt class="descname">iterate</tt><big>(</big><big>)</big><a class="headerlink" href="#celery.task.TaskSet.iterate" title="Permalink to this definition">¶</a></dt>
  351. <dd><p>Iterate over the results returned after calling <a title="celery.task.TaskSet.run" class="reference internal" href="#celery.task.TaskSet.run"><tt class="xref docutils literal"><span class="pre">run()</span></tt></a>.</p>
  352. <p>If any of the tasks raises an exception, the exception will
  353. be re-raised.</p>
  354. </dd></dl>
  355. <dl class="method">
  356. <dt id="celery.task.TaskSet.join">
  357. <tt class="descname">join</tt><big>(</big><em>timeout=None</em><big>)</big><a class="headerlink" href="#celery.task.TaskSet.join" title="Permalink to this definition">¶</a></dt>
  358. <dd><p>Gather the results for all of the tasks in the taskset,
  359. and return a list with them ordered by the order of which they
  360. were called.</p>
  361. <table class="docutils field-list" frame="void" rules="none">
  362. <col class="field-name" />
  363. <col class="field-body" />
  364. <tbody valign="top">
  365. <tr class="field"><th class="field-name">Parameter:</th><td class="field-body"><em>timeout</em> &#8211; The time in seconds, how long
  366. it will wait for results, before the operation times out.</td>
  367. </tr>
  368. <tr class="field"><th class="field-name" colspan="2">Raises <a title="celery.timer.TimeoutError" class="reference external" href="celery.timer.html#celery.timer.TimeoutError">celery.timer.TimeoutError</a>:</th></tr>
  369. <tr><td>&nbsp;</td><td class="field-body">if <tt class="docutils literal"><span class="pre">timeout</span></tt> is not <tt class="xref docutils literal"><span class="pre">None</span></tt>
  370. and the operation takes longer than <tt class="docutils literal"><span class="pre">timeout</span></tt> seconds.</td>
  371. </tr>
  372. </tbody>
  373. </table>
  374. <p>If any of the tasks raises an exception, the exception
  375. will be reraised by <a title="celery.task.TaskSet.join" class="reference internal" href="#celery.task.TaskSet.join"><tt class="xref docutils literal"><span class="pre">join()</span></tt></a>.</p>
  376. <table class="docutils field-list" frame="void" rules="none">
  377. <col class="field-name" />
  378. <col class="field-body" />
  379. <tbody valign="top">
  380. <tr class="field"><th class="field-name">Returns:</th><td class="field-body">list of return values for all tasks in the taskset.</td>
  381. </tr>
  382. </tbody>
  383. </table>
  384. </dd></dl>
  385. <dl class="classmethod">
  386. <dt id="celery.task.TaskSet.map">
  387. <em class="property">
  388. classmethod </em><tt class="descname">map</tt><big>(</big><em>func</em>, <em>args</em>, <em>timeout=None</em><big>)</big><a class="headerlink" href="#celery.task.TaskSet.map" title="Permalink to this definition">¶</a></dt>
  389. <dd>Distribute processing of the arguments and collect the results.</dd></dl>
  390. <dl class="classmethod">
  391. <dt id="celery.task.TaskSet.map_async">
  392. <em class="property">
  393. classmethod </em><tt class="descname">map_async</tt><big>(</big><em>func</em>, <em>args</em>, <em>timeout=None</em><big>)</big><a class="headerlink" href="#celery.task.TaskSet.map_async" title="Permalink to this definition">¶</a></dt>
  394. <dd><p>Distribute processing of the arguments and collect the results
  395. asynchronously.</p>
  396. <table class="docutils field-list" frame="void" rules="none">
  397. <col class="field-name" />
  398. <col class="field-body" />
  399. <tbody valign="top">
  400. <tr class="field"><th class="field-name">Returns:</th><td class="field-body"><a title="celery.result.AsyncResult" class="reference external" href="celery.result.html#celery.result.AsyncResult"><tt class="xref docutils literal"><span class="pre">celery.result.AsyncResult</span></tt></a> instance.</td>
  401. </tr>
  402. </tbody>
  403. </table>
  404. </dd></dl>
  405. <dl class="classmethod">
  406. <dt id="celery.task.TaskSet.remote_execute">
  407. <em class="property">
  408. classmethod </em><tt class="descname">remote_execute</tt><big>(</big><em>func</em>, <em>args</em><big>)</big><a class="headerlink" href="#celery.task.TaskSet.remote_execute" title="Permalink to this definition">¶</a></dt>
  409. <dd>Apply <tt class="docutils literal"><span class="pre">args</span></tt> to function by distributing the args to the
  410. celery server(s).</dd></dl>
  411. <dl class="method">
  412. <dt id="celery.task.TaskSet.run">
  413. <tt class="descname">run</tt><big>(</big><big>)</big><a class="headerlink" href="#celery.task.TaskSet.run" title="Permalink to this definition">¶</a></dt>
  414. <dd><p>Run all tasks in the taskset.</p>
  415. <table class="docutils field-list" frame="void" rules="none">
  416. <col class="field-name" />
  417. <col class="field-body" />
  418. <tbody valign="top">
  419. <tr class="field"><th class="field-name">Returns:</th><td class="field-body">A <a title="celery.result.TaskSetResult" class="reference external" href="celery.result.html#celery.result.TaskSetResult"><tt class="xref docutils literal"><span class="pre">celery.result.TaskSetResult</span></tt></a> instance.</td>
  420. </tr>
  421. </tbody>
  422. </table>
  423. <p>Example</p>
  424. <div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">ts</span> <span class="o">=</span> <span class="n">TaskSet</span><span class="p">(</span><span class="n">RefreshFeedTask</span><span class="p">,</span> <span class="p">[</span>
  425. <span class="gp">... </span> <span class="p">[</span><span class="s">&quot;http://foo.com/rss&quot;</span><span class="p">,</span> <span class="p">{}],</span>
  426. <span class="gp">... </span> <span class="p">[</span><span class="s">&quot;http://bar.com/rss&quot;</span><span class="p">,</span> <span class="p">{}],</span>
  427. <span class="gp">... </span><span class="p">)</span>
  428. <span class="gp">&gt;&gt;&gt; </span><span class="n">result</span> <span class="o">=</span> <span class="n">ts</span><span class="o">.</span><span class="n">run</span><span class="p">()</span>
  429. <span class="gp">&gt;&gt;&gt; </span><span class="n">result</span><span class="o">.</span><span class="n">taskset_id</span>
  430. <span class="go">&quot;d2c9b261-8eff-4bfb-8459-1e1b72063514&quot;</span>
  431. <span class="gp">&gt;&gt;&gt; </span><span class="n">result</span><span class="o">.</span><span class="n">subtask_ids</span>
  432. <span class="go">[&quot;b4996460-d959-49c8-aeb9-39c530dcde25&quot;,</span>
  433. <span class="go">&quot;598d2d18-ab86-45ca-8b4f-0779f5d6a3cb&quot;]</span>
  434. <span class="gp">&gt;&gt;&gt; </span><span class="n">result</span><span class="o">.</span><span class="n">waiting</span><span class="p">()</span>
  435. <span class="go">True</span>
  436. <span class="gp">&gt;&gt;&gt; </span><span class="n">time</span><span class="o">.</span><span class="n">sleep</span><span class="p">(</span><span class="mf">10</span><span class="p">)</span>
  437. <span class="gp">&gt;&gt;&gt; </span><span class="n">result</span><span class="o">.</span><span class="n">ready</span><span class="p">()</span>
  438. <span class="go">True</span>
  439. <span class="gp">&gt;&gt;&gt; </span><span class="n">result</span><span class="o">.</span><span class="n">successful</span><span class="p">()</span>
  440. <span class="go">True</span>
  441. <span class="gp">&gt;&gt;&gt; </span><span class="n">result</span><span class="o">.</span><span class="n">failed</span><span class="p">()</span>
  442. <span class="go">False</span>
  443. <span class="gp">&gt;&gt;&gt; </span><span class="n">result</span><span class="o">.</span><span class="n">join</span><span class="p">()</span>
  444. <span class="go">[True, True]</span>
  445. </pre></div>
  446. </div>
  447. </dd></dl>
  448. </dd></dl>
  449. <dl class="function">
  450. <dt id="celery.task.apply_async">
  451. <tt class="descclassname">celery.task.</tt><tt class="descname">apply_async</tt><big>(</big><em>task</em>, <em>args=None</em>, <em>kwargs=None</em>, <em>routing_key=None</em>, <em>immediate=None</em>, <em>mandatory=None</em>, <em>connection=None</em>, <em>connect_timeout=None</em>, <em>priority=None</em><big>)</big><a class="headerlink" href="#celery.task.apply_async" title="Permalink to this definition">¶</a></dt>
  452. <dd><p>Run a task asynchronously by the celery daemon(s).</p>
  453. <table class="docutils field-list" frame="void" rules="none">
  454. <col class="field-name" />
  455. <col class="field-body" />
  456. <tbody valign="top">
  457. <tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
  458. <li><em>task</em> &#8211; The task to run (a callable object, or a <a title="celery.task.Task" class="reference internal" href="#celery.task.Task"><tt class="xref docutils literal"><span class="pre">Task</span></tt></a>
  459. instance</li>
  460. <li><em>args</em> &#8211; The positional arguments to pass on to the task (a <tt class="docutils literal"><span class="pre">list</span></tt>).</li>
  461. <li><em>kwargs</em> &#8211; The keyword arguments to pass on to the task (a <tt class="docutils literal"><span class="pre">dict</span></tt>)</li>
  462. <li><em>routing_key</em> &#8211; The routing key used to route the task to a worker
  463. server.</li>
  464. <li><em>immediate</em> &#8211; Request immediate delivery. Will raise an exception
  465. if the task cannot be routed to a worker immediately.</li>
  466. <li><em>mandatory</em> &#8211; Mandatory routing. Raises an exception if there&#8217;s
  467. no running workers able to take on this task.</li>
  468. <li><em>connection</em> &#8211; Re-use existing AMQP connection.
  469. The <tt class="docutils literal"><span class="pre">connect_timeout</span></tt> argument is not respected if this is set.</li>
  470. <li><em>connect_timeout</em> &#8211; The timeout in seconds, before we give up
  471. on establishing a connection to the AMQP server.</li>
  472. <li><em>priority</em> &#8211; The task priority, a number between <tt class="docutils literal"><span class="pre">0</span></tt> and <tt class="docutils literal"><span class="pre">9</span></tt>.</li>
  473. </ul>
  474. </td>
  475. </tr>
  476. </tbody>
  477. </table>
  478. </dd></dl>
  479. <dl class="function">
  480. <dt id="celery.task.delay_task">
  481. <tt class="descclassname">celery.task.</tt><tt class="descname">delay_task</tt><big>(</big><em>task_name</em>, <em>*args</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#celery.task.delay_task" title="Permalink to this definition">¶</a></dt>
  482. <dd><p>Delay a task for execution by the <tt class="docutils literal"><span class="pre">celery</span></tt> daemon.</p>
  483. <table class="docutils field-list" frame="void" rules="none">
  484. <col class="field-name" />
  485. <col class="field-body" />
  486. <tbody valign="top">
  487. <tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  488. <li><em>task_name</em> &#8211; the name of a task registered in the task registry.</li>
  489. <li><em>*args</em> &#8211; positional arguments to pass on to the task.</li>
  490. <li><em>**kwargs</em> &#8211; keyword arguments to pass on to the task.</li>
  491. </ul>
  492. </td>
  493. </tr>
  494. <tr class="field"><th class="field-name" colspan="2">Raises <a title="celery.registry.NotRegistered" class="reference external" href="celery.registry.html#celery.registry.NotRegistered">celery.registry.NotRegistered</a>:</th></tr>
  495. <tr><td>&nbsp;</td><td class="field-body"><p class="first">exception if no such task
  496. has been registered in the task registry.</p>
  497. </td>
  498. </tr>
  499. <tr class="field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last"><a title="celery.result.AsyncResult" class="reference external" href="celery.result.html#celery.result.AsyncResult"><tt class="xref docutils literal"><span class="pre">celery.result.AsyncResult</span></tt></a>.</p>
  500. </td>
  501. </tr>
  502. </tbody>
  503. </table>
  504. <p>Example</p>
  505. <div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">r</span> <span class="o">=</span> <span class="n">delay_task</span><span class="p">(</span><span class="s">&quot;update_record&quot;</span><span class="p">,</span> <span class="n">name</span><span class="o">=</span><span class="s">&quot;George Constanza&quot;</span><span class="p">,</span> <span class="n">age</span><span class="o">=</span><span class="mf">32</span><span class="p">)</span>
  506. <span class="gp">&gt;&gt;&gt; </span><span class="n">r</span><span class="o">.</span><span class="n">ready</span><span class="p">()</span>
  507. <span class="go">True</span>
  508. <span class="gp">&gt;&gt;&gt; </span><span class="n">r</span><span class="o">.</span><span class="n">result</span>
  509. <span class="go">&quot;Record was updated&quot;</span>
  510. </pre></div>
  511. </div>
  512. </dd></dl>
  513. <dl class="function">
  514. <dt id="celery.task.discard_all">
  515. <tt class="descclassname">celery.task.</tt><tt class="descname">discard_all</tt><big>(</big><big>)</big><a class="headerlink" href="#celery.task.discard_all" title="Permalink to this definition">¶</a></dt>
  516. <dd><p>Discard all waiting tasks.</p>
  517. <p>This will ignore all tasks waiting for execution, and they will
  518. be deleted from the messaging server.</p>
  519. <table class="docutils field-list" frame="void" rules="none">
  520. <col class="field-name" />
  521. <col class="field-body" />
  522. <tbody valign="top">
  523. <tr class="field"><th class="field-name">Returns:</th><td class="field-body">the number of tasks discarded.</td>
  524. </tr>
  525. <tr class="field"><th class="field-name">Return type:</th><td class="field-body">int</td>
  526. </tr>
  527. </tbody>
  528. </table>
  529. </dd></dl>
  530. <dl class="function">
  531. <dt id="celery.task.dmap">
  532. <tt class="descclassname">celery.task.</tt><tt class="descname">dmap</tt><big>(</big><em>func</em>, <em>args</em>, <em>timeout=None</em><big>)</big><a class="headerlink" href="#celery.task.dmap" title="Permalink to this definition">¶</a></dt>
  533. <dd><p>Distribute processing of the arguments and collect the results.</p>
  534. <p>Example</p>
  535. <div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">celery.task</span> <span class="kn">import</span> <span class="nb">map</span>
  536. <span class="gp">&gt;&gt;&gt; </span><span class="kn">import</span> <span class="nn">operator</span>
  537. <span class="gp">&gt;&gt;&gt; </span><span class="n">dmap</span><span class="p">(</span><span class="n">operator</span><span class="o">.</span><span class="n">add</span><span class="p">,</span> <span class="p">[[</span><span class="mf">2</span><span class="p">,</span> <span class="mf">2</span><span class="p">],</span> <span class="p">[</span><span class="mf">4</span><span class="p">,</span> <span class="mf">4</span><span class="p">],</span> <span class="p">[</span><span class="mf">8</span><span class="p">,</span> <span class="mf">8</span><span class="p">]])</span>
  538. <span class="go">[4, 8, 16]</span>
  539. </pre></div>
  540. </div>
  541. </dd></dl>
  542. <dl class="function">
  543. <dt id="celery.task.dmap_async">
  544. <tt class="descclassname">celery.task.</tt><tt class="descname">dmap_async</tt><big>(</big><em>func</em>, <em>args</em>, <em>timeout=None</em><big>)</big><a class="headerlink" href="#celery.task.dmap_async" title="Permalink to this definition">¶</a></dt>
  545. <dd><p>Distribute processing of the arguments and collect the results
  546. asynchronously.</p>
  547. <table class="docutils field-list" frame="void" rules="none">
  548. <col class="field-name" />
  549. <col class="field-body" />
  550. <tbody valign="top">
  551. <tr class="field"><th class="field-name">Returns:</th><td class="field-body"><a title="celery.result.AsyncResult" class="reference external" href="celery.result.html#celery.result.AsyncResult"><tt class="xref docutils literal"><span class="pre">celery.result.AsyncResult</span></tt></a> object.</td>
  552. </tr>
  553. </tbody>
  554. </table>
  555. <p>Example</p>
  556. <div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">celery.task</span> <span class="kn">import</span> <span class="n">dmap_async</span>
  557. <span class="gp">&gt;&gt;&gt; </span><span class="kn">import</span> <span class="nn">operator</span>
  558. <span class="gp">&gt;&gt;&gt; </span><span class="n">presult</span> <span class="o">=</span> <span class="n">dmap_async</span><span class="p">(</span><span class="n">operator</span><span class="o">.</span><span class="n">add</span><span class="p">,</span> <span class="p">[[</span><span class="mf">2</span><span class="p">,</span> <span class="mf">2</span><span class="p">],</span> <span class="p">[</span><span class="mf">4</span><span class="p">,</span> <span class="mf">4</span><span class="p">],</span> <span class="p">[</span><span class="mf">8</span><span class="p">,</span> <span class="mf">8</span><span class="p">]])</span>
  559. <span class="gp">&gt;&gt;&gt; </span><span class="n">presult</span>
  560. <span class="go">&lt;AsyncResult: 373550e8-b9a0-4666-bc61-ace01fa4f91d&gt;</span>
  561. <span class="gp">&gt;&gt;&gt; </span><span class="n">presult</span><span class="o">.</span><span class="n">status</span>
  562. <span class="go">&#39;DONE&#39;</span>
  563. <span class="gp">&gt;&gt;&gt; </span><span class="n">presult</span><span class="o">.</span><span class="n">result</span>
  564. <span class="go">[4, 8, 16]</span>
  565. </pre></div>
  566. </div>
  567. </dd></dl>
  568. <dl class="function">
  569. <dt id="celery.task.execute_remote">
  570. <tt class="descclassname">celery.task.</tt><tt class="descname">execute_remote</tt><big>(</big><em>func</em>, <em>*args</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#celery.task.execute_remote" title="Permalink to this definition">¶</a></dt>
  571. <dd><p>Execute arbitrary function/object remotely.</p>
  572. <table class="docutils field-list" frame="void" rules="none">
  573. <col class="field-name" />
  574. <col class="field-body" />
  575. <tbody valign="top">
  576. <tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
  577. <li><em>func</em> &#8211; A callable function or object.</li>
  578. <li><em>*args</em> &#8211; Positional arguments to apply to the function.</li>
  579. <li><em>**kwargs</em> &#8211; Keyword arguments to apply to the function.</li>
  580. </ul>
  581. </td>
  582. </tr>
  583. </tbody>
  584. </table>
  585. <p>The object must be picklable, so you can&#8217;t use lambdas or functions
  586. defined in the REPL (the objects must have an associated module).</p>
  587. <table class="docutils field-list" frame="void" rules="none">
  588. <col class="field-name" />
  589. <col class="field-body" />
  590. <tbody valign="top">
  591. <tr class="field"><th class="field-name">Returns:</th><td class="field-body">class:<cite>celery.result.AsyncResult</cite>.</td>
  592. </tr>
  593. </tbody>
  594. </table>
  595. </dd></dl>
  596. <dl class="function">
  597. <dt id="celery.task.is_done">
  598. <tt class="descclassname">celery.task.</tt><tt class="descname">is_done</tt><big>(</big><em>task_id</em><big>)</big><a class="headerlink" href="#celery.task.is_done" title="Permalink to this definition">¶</a></dt>
  599. <dd><p>Returns <tt class="xref docutils literal"><span class="pre">True</span></tt> if task with <tt class="docutils literal"><span class="pre">task_id</span></tt> has been executed.</p>
  600. <table class="docutils field-list" frame="void" rules="none">
  601. <col class="field-name" />
  602. <col class="field-body" />
  603. <tbody valign="top">
  604. <tr class="field"><th class="field-name">Return type:</th><td class="field-body">bool</td>
  605. </tr>
  606. </tbody>
  607. </table>
  608. </dd></dl>
  609. </div>
  610. </div>
  611. </div>
  612. </div>
  613. </div>
  614. <div class="sidebar">
  615. <h3>Contents</h3>
  616. <ul class="current">
  617. <li class="toctree-l1"><a class="reference external" href="../introduction.html">celery - Distributed Task Queue for Django.</a></li>
  618. <li class="toctree-l1"><a class="reference external" href="../faq.html">Frequently Asked Questions</a></li>
  619. <li class="toctree-l1 current"><a class="reference external" href="index.html">Module API Reference</a><ul class="current">
  620. <li class="toctree-l2 current"><a class="current reference external" href="">Tasks - celery.task</a></li>
  621. <li class="toctree-l2"><a class="reference external" href="celery.result.html">Task Result - celery.result</a></li>
  622. <li class="toctree-l2"><a class="reference external" href="celery.registry.html">Task Registry - celery.registry</a></li>
  623. <li class="toctree-l2"><a class="reference external" href="celery.discovery.html">Task Discovery - celery.discovery</a></li>
  624. <li class="toctree-l2"><a class="reference external" href="celery.worker.html">Multiprocessing Worker - celery.worker</a></li>
  625. <li class="toctree-l2"><a class="reference external" href="celery.pool.html">Task Pool - celery.pool</a></li>
  626. <li class="toctree-l2"><a class="reference external" href="celery.backends.html">Backends - celery.backends</a></li>
  627. <li class="toctree-l2"><a class="reference external" href="celery.backends.base.html">Backend: Base - celery.backends.base</a></li>
  628. <li class="toctree-l2"><a class="reference external" href="celery.backends.database.html">Backend: Database - celery.backends.database</a></li>
  629. <li class="toctree-l2"><a class="reference external" href="celery.backends.cache.html">Backend: Cache - celery.backends.cache</a></li>
  630. <li class="toctree-l2"><a class="reference external" href="celery.backends.tyrant.html">Backend: Tokyo Tyrant - celery.backends.tyrant</a></li>
  631. <li class="toctree-l2"><a class="reference external" href="celery.conf.html">Configuration - celery.conf</a></li>
  632. <li class="toctree-l2"><a class="reference external" href="celery.datastructures.html">Datastructures - celery.datastructures</a></li>
  633. <li class="toctree-l2"><a class="reference external" href="celery.log.html">Logging - celery.log</a></li>
  634. <li class="toctree-l2"><a class="reference external" href="celery.managers.html">Django Model Managers - celery.managers</a></li>
  635. <li class="toctree-l2"><a class="reference external" href="celery.models.html">Django Models - celery.models</a></li>
  636. <li class="toctree-l2"><a class="reference external" href="celery.messaging.html">Messaging - celery.messaging</a></li>
  637. <li class="toctree-l2"><a class="reference external" href="celery.timer.html">Timers - celery.timer</a></li>
  638. <li class="toctree-l2"><a class="reference external" href="celery.bin.celeryd.html">Celery Worker Daemon - celery.bin.celeryd</a></li>
  639. </ul>
  640. </li>
  641. <li class="toctree-l1"><a class="reference external" href="../changelog.html">Change history</a></li>
  642. </ul>
  643. <h3 style="margin-top: 1.5em;">Search</h3>
  644. <form class="search" action="../search.html" method="get">
  645. <input type="text" name="q" size="18" />
  646. <input type="submit" value="Go" />
  647. <input type="hidden" name="check_keywords" value="yes" />
  648. <input type="hidden" name="area" value="default" />
  649. </form>
  650. <p class="searchtip" style="font-size: 90%">
  651. Enter search terms or a module, class or function name.
  652. </p>
  653. </div>
  654. <div class="clearer"></div>
  655. </div>
  656. </div>
  657. <div class="footer-wrapper">
  658. <div class="footer">
  659. <div class="left">
  660. <a href="../genindex.html" title="General Index"
  661. >index</a> |
  662. <a href="../modindex.html" title="Global Module Index"
  663. >modules</a> |
  664. <a href="celery.result.html" title="Task Result - celery.result"
  665. >next</a> |
  666. <a href="index.html" title="Module API Reference"
  667. >previous</a>
  668. <br/>
  669. <a href="../sources/reference/celery.task.txt"
  670. rel="nofollow">Show Source</a>
  671. </div>
  672. <div class="right">
  673. &copy; Copyright 2009, Ask Solem.<br/>
  674. Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 0.6.1.
  675. </div>
  676. <div class="clearer"></div>
  677. </div>
  678. </div>
  679. </body>
  680. </html>