celery.task.html 47 KB

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