celery.task.base.html 47 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707
  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>Defining Tasks - celery.task.base &mdash; Celery v0.7.0 (unstable) documentation</title>
  7. <link rel="stylesheet" href="../static/nature.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.7.0 (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.7.0 (unstable) documentation" href="../index.html" />
  21. <link rel="up" title="Module API Reference" href="index.html" />
  22. <link rel="next" title="Executing Tasks - celery.execute" href="celery.execute.html" />
  23. <link rel="prev" title="Module API Reference" href="index.html" />
  24. </head>
  25. <body>
  26. <div class="related">
  27. <h3>Navigation</h3>
  28. <ul>
  29. <li class="right" style="margin-right: 10px">
  30. <a href="../genindex.html" title="General Index"
  31. accesskey="I">index</a></li>
  32. <li class="right" >
  33. <a href="../modindex.html" title="Global Module Index"
  34. accesskey="M">modules</a> |</li>
  35. <li class="right" >
  36. <a href="celery.execute.html" title="Executing Tasks - celery.execute"
  37. accesskey="N">next</a> |</li>
  38. <li class="right" >
  39. <a href="index.html" title="Module API Reference"
  40. accesskey="P">previous</a> |</li>
  41. <li><a href="../index.html">Celery v0.7.0 (unstable) documentation</a> &raquo;</li>
  42. <li><a href="index.html" accesskey="U">Module API Reference</a> &raquo;</li>
  43. </ul>
  44. </div>
  45. <div class="document">
  46. <div class="documentwrapper">
  47. <div class="bodywrapper">
  48. <div class="body">
  49. <div class="section" id="module-celery.task.base">
  50. <h1>Defining Tasks - celery.task.base<a class="headerlink" href="#module-celery.task.base" title="Permalink to this headline">¶</a></h1>
  51. <dl class="class">
  52. <dt id="celery.task.base.AsynchronousMapTask">
  53. <em class="property">
  54. class </em><tt class="descclassname">celery.task.base.</tt><tt class="descname">AsynchronousMapTask</tt><a class="headerlink" href="#celery.task.base.AsynchronousMapTask" title="Permalink to this definition">¶</a></dt>
  55. <dd><p>Task used internally by <tt class="xref docutils literal"><span class="pre">dmap_async()</span></tt> and
  56. <a title="celery.task.base.TaskSet.map_async" class="reference internal" href="#celery.task.base.TaskSet.map_async"><tt class="xref docutils literal"><span class="pre">TaskSet.map_async()</span></tt></a>.</p>
  57. <dl class="method">
  58. <dt id="celery.task.base.AsynchronousMapTask.run">
  59. <tt class="descname">run</tt><big>(</big><em>serfunc</em>, <em>args</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#celery.task.base.AsynchronousMapTask.run" title="Permalink to this definition">¶</a></dt>
  60. <dd>The method run by <tt class="docutils literal"><span class="pre">celeryd</span></tt>.</dd></dl>
  61. </dd></dl>
  62. <dl class="class">
  63. <dt id="celery.task.base.ExecuteRemoteTask">
  64. <em class="property">
  65. class </em><tt class="descclassname">celery.task.base.</tt><tt class="descname">ExecuteRemoteTask</tt><a class="headerlink" href="#celery.task.base.ExecuteRemoteTask" title="Permalink to this definition">¶</a></dt>
  66. <dd><p>Execute an arbitrary function or object.</p>
  67. <p><em>Note</em> You probably want <tt class="xref docutils literal"><span class="pre">execute_remote()</span></tt> instead, which this
  68. is an internal component of.</p>
  69. <p>The object must be pickleable, so you can&#8217;t use lambdas or functions
  70. defined in the REPL (that is the python shell, or <tt class="docutils literal"><span class="pre">ipython</span></tt>).</p>
  71. <dl class="method">
  72. <dt id="celery.task.base.ExecuteRemoteTask.run">
  73. <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.base.ExecuteRemoteTask.run" title="Permalink to this definition">¶</a></dt>
  74. <dd><table class="docutils field-list" frame="void" rules="none">
  75. <col class="field-name" />
  76. <col class="field-body" />
  77. <tbody valign="top">
  78. <tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
  79. <li><em>ser_callable</em> &#8211; A pickled function or callable object.</li>
  80. <li><em>fargs</em> &#8211; Positional arguments to apply to the function.</li>
  81. <li><em>fkwargs</em> &#8211; Keyword arguments to apply to the function.</li>
  82. </ul>
  83. </td>
  84. </tr>
  85. </tbody>
  86. </table>
  87. </dd></dl>
  88. </dd></dl>
  89. <dl class="class">
  90. <dt id="celery.task.base.PeriodicTask">
  91. <em class="property">
  92. class </em><tt class="descclassname">celery.task.base.</tt><tt class="descname">PeriodicTask</tt><a class="headerlink" href="#celery.task.base.PeriodicTask" title="Permalink to this definition">¶</a></dt>
  93. <dd><p>A periodic task is a task that behaves like a <em>cron</em> job.</p>
  94. <dl class="attribute">
  95. <dt id="celery.task.base.PeriodicTask.run_every">
  96. <tt class="descname">run_every</tt><a class="headerlink" href="#celery.task.base.PeriodicTask.run_every" title="Permalink to this definition">¶</a></dt>
  97. <dd><em>REQUIRED</em> Defines how often the task is run (its interval),
  98. it can be either a <tt class="xref docutils literal"><span class="pre">datetime.timedelta</span></tt> object or an
  99. integer specifying the time in seconds.</dd></dl>
  100. <table class="docutils field-list" frame="void" rules="none">
  101. <col class="field-name" />
  102. <col class="field-body" />
  103. <tbody valign="top">
  104. <tr class="field"><th class="field-name" colspan="2">Raises NotImplementedError:</th></tr>
  105. <tr><td>&nbsp;</td><td class="field-body">if the <a title="celery.task.base.PeriodicTask.run_every" class="reference internal" href="#celery.task.base.PeriodicTask.run_every"><tt class="xref docutils literal"><span class="pre">run_every</span></tt></a> attribute is
  106. not defined.</td>
  107. </tr>
  108. </tbody>
  109. </table>
  110. <p>You have to register the periodic task in the task registry.</p>
  111. <p>Example</p>
  112. <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>
  113. <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>
  114. <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>
  115. <span class="gp">... </span> <span class="n">name</span> <span class="o">=</span> <span class="s">&quot;my_periodic_task&quot;</span>
  116. <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>
  117. <span class="gp">...</span>
  118. <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>
  119. <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>
  120. <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>
  121. <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>
  122. </pre></div>
  123. </div>
  124. </dd></dl>
  125. <dl class="class">
  126. <dt id="celery.task.base.Task">
  127. <em class="property">
  128. class </em><tt class="descclassname">celery.task.base.</tt><tt class="descname">Task</tt><a class="headerlink" href="#celery.task.base.Task" title="Permalink to this definition">¶</a></dt>
  129. <dd><p>A task that can be delayed for execution by the <tt class="docutils literal"><span class="pre">celery</span></tt> daemon.</p>
  130. <p>All subclasses of <a title="celery.task.base.Task" class="reference internal" href="#celery.task.base.Task"><tt class="xref docutils literal"><span class="pre">Task</span></tt></a> must define the <a title="celery.task.base.Task.run" class="reference internal" href="#celery.task.base.Task.run"><tt class="xref docutils literal"><span class="pre">run()</span></tt></a> method,
  131. which is the actual method the <tt class="docutils literal"><span class="pre">celery</span></tt> daemon executes.</p>
  132. <p>The <a title="celery.task.base.Task.run" class="reference internal" href="#celery.task.base.Task.run"><tt class="xref docutils literal"><span class="pre">run()</span></tt></a> method supports both positional, and keyword arguments.</p>
  133. <dl class="attribute">
  134. <dt id="celery.task.base.Task.name">
  135. <tt class="descname">name</tt><a class="headerlink" href="#celery.task.base.Task.name" title="Permalink to this definition">¶</a></dt>
  136. <dd><em>REQUIRED</em> All subclasses of <a title="celery.task.base.Task" class="reference internal" href="#celery.task.base.Task"><tt class="xref docutils literal"><span class="pre">Task</span></tt></a> has to define the
  137. <a title="celery.task.base.Task.name" class="reference internal" href="#celery.task.base.Task.name"><tt class="xref docutils literal"><span class="pre">name</span></tt></a> attribute. This is the name of the task, registered
  138. in the task registry, and passed to <tt class="xref docutils literal"><span class="pre">delay_task()</span></tt>.</dd></dl>
  139. <dl class="attribute">
  140. <dt id="celery.task.base.Task.type">
  141. <tt class="descname">type</tt><a class="headerlink" href="#celery.task.base.Task.type" title="Permalink to this definition">¶</a></dt>
  142. <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>,
  143. however if you want a periodic task, you should subclass
  144. <a title="celery.task.base.PeriodicTask" class="reference internal" href="#celery.task.base.PeriodicTask"><tt class="xref docutils literal"><span class="pre">PeriodicTask</span></tt></a> instead.</dd></dl>
  145. <dl class="attribute">
  146. <dt id="celery.task.base.Task.routing_key">
  147. <tt class="descname">routing_key</tt><a class="headerlink" href="#celery.task.base.Task.routing_key" title="Permalink to this definition">¶</a></dt>
  148. <dd>Override the global default <tt class="docutils literal"><span class="pre">routing_key</span></tt> for this task.</dd></dl>
  149. <dl class="attribute">
  150. <dt id="celery.task.base.Task.exchange">
  151. <tt class="descname">exchange</tt><a class="headerlink" href="#celery.task.base.Task.exchange" title="Permalink to this definition">¶</a></dt>
  152. <dd>Override the global default <tt class="docutils literal"><span class="pre">exchange</span></tt> for this task.</dd></dl>
  153. <dl class="attribute">
  154. <dt id="celery.task.base.Task.mandatory">
  155. <tt class="descname">mandatory</tt><a class="headerlink" href="#celery.task.base.Task.mandatory" title="Permalink to this definition">¶</a></dt>
  156. <dd>If set, the message has mandatory routing. By default the message
  157. is silently dropped by the broker if it can&#8217;t be routed to a queue.
  158. However - If the message is mandatory, an exception will be raised
  159. instead.</dd></dl>
  160. <dl class="attribute">
  161. <dt>
  162. <tt class="descname">immediate:</tt></dt>
  163. <dd>Request immediate delivery. If the message cannot be routed to a
  164. task worker immediately, an exception will be raised. This is
  165. instead of the default behaviour, where the broker will accept and
  166. queue the message, but with no guarantee that the message will ever
  167. be consumed.</dd></dl>
  168. <dl class="attribute">
  169. <dt>
  170. <tt class="descname">priority:</tt></dt>
  171. <dd>The message priority. A number from <tt class="docutils literal"><span class="pre">0</span></tt> to <tt class="docutils literal"><span class="pre">9</span></tt>.</dd></dl>
  172. <dl class="attribute">
  173. <dt id="celery.task.base.Task.max_retries">
  174. <tt class="descname">max_retries</tt><a class="headerlink" href="#celery.task.base.Task.max_retries" title="Permalink to this definition">¶</a></dt>
  175. <dd>Maximum number of retries before giving up.</dd></dl>
  176. <dl class="attribute">
  177. <dt id="celery.task.base.Task.default_retry_delay">
  178. <tt class="descname">default_retry_delay</tt><a class="headerlink" href="#celery.task.base.Task.default_retry_delay" title="Permalink to this definition">¶</a></dt>
  179. <dd>Defeault time in seconds before a retry of the task should be
  180. executed. Default is a 1 minute delay.</dd></dl>
  181. <dl class="attribute">
  182. <dt id="celery.task.base.Task.ignore_result">
  183. <tt class="descname">ignore_result</tt><a class="headerlink" href="#celery.task.base.Task.ignore_result" title="Permalink to this definition">¶</a></dt>
  184. <dd>Don&#8217;t store the status and return value. This means you can&#8217;t
  185. use the <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> to check if the task is
  186. done, or get its return value. Only use if you need the performance
  187. and is able live without these features. Any exceptions raised will
  188. store the return value/status as usual.</dd></dl>
  189. <dl class="attribute">
  190. <dt id="celery.task.base.Task.disable_error_emails">
  191. <tt class="descname">disable_error_emails</tt><a class="headerlink" href="#celery.task.base.Task.disable_error_emails" title="Permalink to this definition">¶</a></dt>
  192. <dd>Disable all error e-mails for this task (only applicable if
  193. <tt class="docutils literal"><span class="pre">settings.SEND_CELERY_ERROR_EMAILS</span></tt> is on.)</dd></dl>
  194. <table class="docutils field-list" frame="void" rules="none">
  195. <col class="field-name" />
  196. <col class="field-body" />
  197. <tbody valign="top">
  198. <tr class="field"><th class="field-name" colspan="2">Raises NotImplementedError:</th></tr>
  199. <tr><td>&nbsp;</td><td class="field-body">if the <a title="celery.task.base.Task.name" class="reference internal" href="#celery.task.base.Task.name"><tt class="xref docutils literal"><span class="pre">name</span></tt></a> attribute is not set.</td>
  200. </tr>
  201. </tbody>
  202. </table>
  203. <p>The resulting class is callable, which if called will apply the
  204. <a title="celery.task.base.Task.run" class="reference internal" href="#celery.task.base.Task.run"><tt class="xref docutils literal"><span class="pre">run()</span></tt></a> method.</p>
  205. <p>Examples</p>
  206. <p>This is a simple task just logging a message,</p>
  207. <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>
  208. <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>
  209. <span class="gp">...</span>
  210. <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>
  211. <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>
  212. <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>
  213. <span class="gp">... </span> <span class="n">some_arg</span><span class="p">))</span>
  214. <span class="gp">... </span> <span class="k">return</span> <span class="mf">42</span>
  215. <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>
  216. </pre></div>
  217. </div>
  218. <p>You can delay the task using the classmethod <a title="celery.task.base.Task.delay" class="reference internal" href="#celery.task.base.Task.delay"><tt class="xref docutils literal"><span class="pre">delay()</span></tt></a>...</p>
  219. <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>
  220. <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>
  221. <span class="go">&#39;DONE&#39;</span>
  222. <span class="gp">&gt;&gt;&gt; </span><span class="n">result</span><span class="o">.</span><span class="n">result</span>
  223. <span class="go">42</span>
  224. </pre></div>
  225. </div>
  226. <p>...or using the <tt class="xref docutils literal"><span class="pre">delay_task()</span></tt> function, by passing the name of
  227. the task.</p>
  228. <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>
  229. <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>
  230. </pre></div>
  231. </div>
  232. <dl class="exception">
  233. <dt id="celery.task.base.Task.MaxRetriesExceededError">
  234. <em class="property">
  235. exception </em><tt class="descname">MaxRetriesExceededError</tt><a class="headerlink" href="#celery.task.base.Task.MaxRetriesExceededError" title="Permalink to this definition">¶</a></dt>
  236. <dd>The tasks max restart limit has been exceeded.</dd></dl>
  237. <dl class="classmethod">
  238. <dt id="celery.task.base.Task.apply">
  239. <em class="property">
  240. classmethod </em><tt class="descclassname">Task.</tt><tt class="descname">apply</tt><big>(</big><em>args=None</em>, <em>kwargs=None</em>, <em>**options</em><big>)</big><a class="headerlink" href="#celery.task.base.Task.apply" title="Permalink to this definition">¶</a></dt>
  241. <dd><p>Execute this task at once, by blocking until the task
  242. has finished executing.</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">Parameters:</th><td class="field-body"><ul class="first simple">
  248. <li><em>args</em> &#8211; positional arguments passed on to the task.</li>
  249. <li><em>kwargs</em> &#8211; keyword arguments passed on to the task.</li>
  250. </ul>
  251. </td>
  252. </tr>
  253. <tr class="field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last"><a title="celery.result.EagerResult" class="reference external" href="celery.result.html#celery.result.EagerResult"><tt class="xref docutils literal"><span class="pre">celery.result.EagerResult</span></tt></a></p>
  254. </td>
  255. </tr>
  256. </tbody>
  257. </table>
  258. <p>See <a title="celery.execute.apply" class="reference external" href="celery.execute.html#celery.execute.apply"><tt class="xref docutils literal"><span class="pre">celery.execute.apply()</span></tt></a>.</p>
  259. </dd></dl>
  260. <dl class="classmethod">
  261. <dt id="celery.task.base.Task.apply_async">
  262. <em class="property">
  263. classmethod </em><tt class="descclassname">Task.</tt><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.base.Task.apply_async" title="Permalink to this definition">¶</a></dt>
  264. <dd><p>Delay this task for execution by the <tt class="docutils literal"><span class="pre">celery</span></tt> daemon(s).</p>
  265. <table class="docutils field-list" frame="void" rules="none">
  266. <col class="field-name" />
  267. <col class="field-body" />
  268. <tbody valign="top">
  269. <tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
  270. <li><em>args</em> &#8211; positional arguments passed on to the task.</li>
  271. <li><em>kwargs</em> &#8211; keyword arguments passed on to the task.</li>
  272. <li><em>**options</em> &#8211; Any keyword arguments to pass on to
  273. <a title="celery.execute.apply_async" class="reference external" href="celery.execute.html#celery.execute.apply_async"><tt class="xref docutils literal"><span class="pre">celery.execute.apply_async()</span></tt></a>.</li>
  274. </ul>
  275. </td>
  276. </tr>
  277. </tbody>
  278. </table>
  279. <p>See <a title="celery.execute.apply_async" class="reference external" href="celery.execute.html#celery.execute.apply_async"><tt class="xref docutils literal"><span class="pre">celery.execute.apply_async()</span></tt></a> for more information.</p>
  280. <table class="docutils field-list" frame="void" rules="none">
  281. <col class="field-name" />
  282. <col class="field-body" />
  283. <tbody valign="top">
  284. <tr class="field"><th class="field-name">Return type:</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></td>
  285. </tr>
  286. </tbody>
  287. </table>
  288. </dd></dl>
  289. <dl class="classmethod">
  290. <dt id="celery.task.base.Task.delay">
  291. <em class="property">
  292. classmethod </em><tt class="descclassname">Task.</tt><tt class="descname">delay</tt><big>(</big><em>*args</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#celery.task.base.Task.delay" title="Permalink to this definition">¶</a></dt>
  293. <dd><p>Delay this task for execution by the <tt class="docutils literal"><span class="pre">celery</span></tt> daemon(s).</p>
  294. <table class="docutils field-list" frame="void" rules="none">
  295. <col class="field-name" />
  296. <col class="field-body" />
  297. <tbody valign="top">
  298. <tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  299. <li><em>*args</em> &#8211; positional arguments passed on to the task.</li>
  300. <li><em>**kwargs</em> &#8211; keyword arguments passed on to the task.</li>
  301. </ul>
  302. </td>
  303. </tr>
  304. <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>
  305. </td>
  306. </tr>
  307. </tbody>
  308. </table>
  309. <p>See <a title="celery.execute.delay_task" class="reference external" href="celery.execute.html#celery.execute.delay_task"><tt class="xref docutils literal"><span class="pre">celery.execute.delay_task()</span></tt></a>.</p>
  310. </dd></dl>
  311. <dl class="method">
  312. <dt id="celery.task.base.Task.get_consumer">
  313. <tt class="descclassname">Task.</tt><tt class="descname">get_consumer</tt><big>(</big><em>connect_timeout=4</em><big>)</big><a class="headerlink" href="#celery.task.base.Task.get_consumer" title="Permalink to this definition">¶</a></dt>
  314. <dd><p>Get a celery task message consumer.</p>
  315. <table class="docutils field-list" frame="void" rules="none">
  316. <col class="field-name" />
  317. <col class="field-body" />
  318. <tbody valign="top">
  319. <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>
  320. </tr>
  321. </tbody>
  322. </table>
  323. <p>Please be sure to close the AMQP connection when you&#8217;re done
  324. with this object. i.e.:</p>
  325. <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>
  326. <span class="gp">&gt;&gt;&gt; </span><span class="c"># do something with consumer</span>
  327. <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>
  328. </pre></div>
  329. </div>
  330. </dd></dl>
  331. <dl class="method">
  332. <dt id="celery.task.base.Task.get_logger">
  333. <tt class="descclassname">Task.</tt><tt class="descname">get_logger</tt><big>(</big><em>**kwargs</em><big>)</big><a class="headerlink" href="#celery.task.base.Task.get_logger" title="Permalink to this definition">¶</a></dt>
  334. <dd><p>Get process-aware logger object.</p>
  335. <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>
  336. </dd></dl>
  337. <dl class="method">
  338. <dt id="celery.task.base.Task.get_publisher">
  339. <tt class="descclassname">Task.</tt><tt class="descname">get_publisher</tt><big>(</big><em>connect_timeout=4</em><big>)</big><a class="headerlink" href="#celery.task.base.Task.get_publisher" title="Permalink to this definition">¶</a></dt>
  340. <dd><p>Get a celery task message publisher.</p>
  341. <table class="docutils field-list" frame="void" rules="none">
  342. <col class="field-name" />
  343. <col class="field-body" />
  344. <tbody valign="top">
  345. <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>
  346. </tr>
  347. </tbody>
  348. </table>
  349. <p>Please be sure to close the AMQP connection when you&#8217;re done
  350. with this object, i.e.:</p>
  351. <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>
  352. <span class="gp">&gt;&gt;&gt; </span><span class="c"># do something with publisher</span>
  353. <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>
  354. </pre></div>
  355. </div>
  356. </dd></dl>
  357. <dl class="method">
  358. <dt id="celery.task.base.Task.on_failure">
  359. <tt class="descclassname">Task.</tt><tt class="descname">on_failure</tt><big>(</big><em>exc</em><big>)</big><a class="headerlink" href="#celery.task.base.Task.on_failure" title="Permalink to this definition">¶</a></dt>
  360. <dd><p>Error handler.</p>
  361. <p>This is run by the worker when the task fails.</p>
  362. <table class="docutils field-list" frame="void" rules="none">
  363. <col class="field-name" />
  364. <col class="field-body" />
  365. <tbody valign="top">
  366. <tr class="field"><th class="field-name">Parameter:</th><td class="field-body"><em>exc</em> &#8211; The exception raised by the task.</td>
  367. </tr>
  368. </tbody>
  369. </table>
  370. </dd></dl>
  371. <dl class="method">
  372. <dt id="celery.task.base.Task.on_retry">
  373. <tt class="descclassname">Task.</tt><tt class="descname">on_retry</tt><big>(</big><em>exc</em><big>)</big><a class="headerlink" href="#celery.task.base.Task.on_retry" title="Permalink to this definition">¶</a></dt>
  374. <dd><p>Retry handler.</p>
  375. <p>This is run by the worker when the task is to be retried.</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">Parameter:</th><td class="field-body"><em>exc</em> &#8211; The exception sent to <a title="celery.task.base.Task.retry" class="reference internal" href="#celery.task.base.Task.retry"><tt class="xref docutils literal"><span class="pre">retry()</span></tt></a>.</td>
  381. </tr>
  382. </tbody>
  383. </table>
  384. </dd></dl>
  385. <dl class="method">
  386. <dt id="celery.task.base.Task.on_success">
  387. <tt class="descclassname">Task.</tt><tt class="descname">on_success</tt><big>(</big><em>retval</em><big>)</big><a class="headerlink" href="#celery.task.base.Task.on_success" title="Permalink to this definition">¶</a></dt>
  388. <dd><p>Success handler.</p>
  389. <p>This is run by the worker when the task executed successfully.</p>
  390. <table class="docutils field-list" frame="void" rules="none">
  391. <col class="field-name" />
  392. <col class="field-body" />
  393. <tbody valign="top">
  394. <tr class="field"><th class="field-name">Parameter:</th><td class="field-body"><em>retval</em> &#8211; The return value of the task.</td>
  395. </tr>
  396. </tbody>
  397. </table>
  398. </dd></dl>
  399. <dl class="method">
  400. <dt id="celery.task.base.Task.retry">
  401. <tt class="descclassname">Task.</tt><tt class="descname">retry</tt><big>(</big><em>args</em>, <em>kwargs</em>, <em>exc=None</em>, <em>throw=True</em>, <em>**options</em><big>)</big><a class="headerlink" href="#celery.task.base.Task.retry" title="Permalink to this definition">¶</a></dt>
  402. <dd><p>Retry the task.</p>
  403. <table class="docutils field-list" frame="void" rules="none">
  404. <col class="field-name" />
  405. <col class="field-body" />
  406. <tbody valign="top">
  407. <tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  408. <li><em>args</em> &#8211; Positional arguments to retry with.</li>
  409. <li><em>kwargs</em> &#8211; Keyword arguments to retry with.</li>
  410. <li><em>exc</em> &#8211; Optional exception to raise instead of
  411. <tt class="xref docutils literal"><span class="pre">MaxRestartsExceededError</span></tt> when the max restart limit has
  412. been exceeded.</li>
  413. <li><em>throw</em> &#8211; Do not raise the
  414. <a title="celery.exceptions.RetryTaskError" class="reference external" href="celery.exceptions.html#celery.exceptions.RetryTaskError"><tt class="xref docutils literal"><span class="pre">celery.exceptions.RetryTaskError</span></tt></a> exception,
  415. that tells the worker that the task is to be retried.</li>
  416. <li><em>countdown</em> &#8211; Time in seconds to delay the retry for.</li>
  417. <li><em>eta</em> &#8211; Explicit time and date to run the retry at (must be a
  418. <tt class="xref docutils literal"><span class="pre">datetime.datetime</span></tt> instance).</li>
  419. <li><em>**options</em> &#8211; Any extra options to pass on to
  420. meth:<cite>apply_async</cite>. See <a title="celery.execute.apply_async" class="reference external" href="celery.execute.html#celery.execute.apply_async"><tt class="xref docutils literal"><span class="pre">celery.execute.apply_async()</span></tt></a>.</li>
  421. </ul>
  422. </td>
  423. </tr>
  424. <tr class="field"><th class="field-name" colspan="2">Raises <a title="celery.exceptions.RetryTaskError" class="reference external" href="celery.exceptions.html#celery.exceptions.RetryTaskError">celery.exceptions.RetryTaskError</a>:</th></tr>
  425. <tr><td>&nbsp;</td><td class="field-body"><p class="first last">To tell the worker that the
  426. task has been re-sent for retry. This always happens except if
  427. the <tt class="docutils literal"><span class="pre">throw</span></tt> keyword argument has been explicitly set
  428. to <tt class="xref docutils literal"><span class="pre">False</span></tt>.</p>
  429. </td>
  430. </tr>
  431. </tbody>
  432. </table>
  433. <p>Example</p>
  434. <div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="k">class</span> <span class="nc">TwitterPostStatusTask</span><span class="p">(</span><span class="n">Task</span><span class="p">):</span>
  435. <span class="gp">... </span>
  436. <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">username</span><span class="p">,</span> <span class="n">password</span><span class="p">,</span> <span class="n">message</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
  437. <span class="gp">... </span> <span class="n">twitter</span> <span class="o">=</span> <span class="n">Twitter</span><span class="p">(</span><span class="n">username</span><span class="p">,</span> <span class="n">password</span><span class="p">)</span>
  438. <span class="gp">... </span> <span class="k">try</span><span class="p">:</span>
  439. <span class="gp">... </span> <span class="n">twitter</span><span class="o">.</span><span class="n">post_status</span><span class="p">(</span><span class="n">message</span><span class="p">)</span>
  440. <span class="gp">... </span> <span class="k">except</span> <span class="n">twitter</span><span class="o">.</span><span class="n">FailWhale</span><span class="p">,</span> <span class="n">exc</span><span class="p">:</span>
  441. <span class="gp">... </span> <span class="c"># Retry in 5 minutes.</span>
  442. <span class="gp">... </span> <span class="bp">self</span><span class="o">.</span><span class="n">retry</span><span class="p">([</span><span class="n">username</span><span class="p">,</span> <span class="n">password</span><span class="p">,</span> <span class="n">message</span><span class="p">],</span> <span class="n">kwargs</span><span class="p">,</span>
  443. <span class="gp">... </span> <span class="n">countdown</span><span class="o">=</span><span class="mf">60</span> <span class="o">*</span> <span class="mf">5</span><span class="p">,</span> <span class="n">exc</span><span class="o">=</span><span class="n">exc</span><span class="p">)</span>
  444. </pre></div>
  445. </div>
  446. </dd></dl>
  447. <dl class="method">
  448. <dt id="celery.task.base.Task.run">
  449. <tt class="descclassname">Task.</tt><tt class="descname">run</tt><big>(</big><em>*args</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#celery.task.base.Task.run" title="Permalink to this definition">¶</a></dt>
  450. <dd><p><em>REQUIRED</em> The actual task.</p>
  451. <p>All subclasses of <a title="celery.task.base.Task" class="reference internal" href="#celery.task.base.Task"><tt class="xref docutils literal"><span class="pre">Task</span></tt></a> must define the run method.</p>
  452. <table class="docutils field-list" frame="void" rules="none">
  453. <col class="field-name" />
  454. <col class="field-body" />
  455. <tbody valign="top">
  456. <tr class="field"><th class="field-name" colspan="2">Raises NotImplementedError:</th></tr>
  457. <tr><td>&nbsp;</td><td class="field-body">by default, so you have to override
  458. this method in your subclass.</td>
  459. </tr>
  460. </tbody>
  461. </table>
  462. </dd></dl>
  463. </dd></dl>
  464. <dl class="class">
  465. <dt id="celery.task.base.TaskSet">
  466. <em class="property">
  467. class </em><tt class="descclassname">celery.task.base.</tt><tt class="descname">TaskSet</tt><big>(</big><em>task</em>, <em>args</em><big>)</big><a class="headerlink" href="#celery.task.base.TaskSet" title="Permalink to this definition">¶</a></dt>
  468. <dd><p>A task containing several subtasks, making it possible
  469. to track how many, or when all of the tasks has been completed.</p>
  470. <table class="docutils field-list" frame="void" rules="none">
  471. <col class="field-name" />
  472. <col class="field-body" />
  473. <tbody valign="top">
  474. <tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
  475. <li><em>task</em> &#8211; The task class or name.
  476. Can either be a fully qualified task name, or a task class.</li>
  477. <li><em>args</em> &#8211; A list of args, kwargs pairs.
  478. 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>
  479. </ul>
  480. </td>
  481. </tr>
  482. </tbody>
  483. </table>
  484. <dl class="attribute">
  485. <dt id="celery.task.base.TaskSet.task_name">
  486. <tt class="descname">task_name</tt><a class="headerlink" href="#celery.task.base.TaskSet.task_name" title="Permalink to this definition">¶</a></dt>
  487. <dd>The name of the task.</dd></dl>
  488. <dl class="attribute">
  489. <dt id="celery.task.base.TaskSet.arguments">
  490. <tt class="descname">arguments</tt><a class="headerlink" href="#celery.task.base.TaskSet.arguments" title="Permalink to this definition">¶</a></dt>
  491. <dd>The arguments, as passed to the task set constructor.</dd></dl>
  492. <dl class="attribute">
  493. <dt id="celery.task.base.TaskSet.total">
  494. <tt class="descname">total</tt><a class="headerlink" href="#celery.task.base.TaskSet.total" title="Permalink to this definition">¶</a></dt>
  495. <dd>Total number of tasks in this task set.</dd></dl>
  496. <p>Example</p>
  497. <blockquote>
  498. <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>
  499. <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>
  500. <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>
  501. <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>
  502. <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>
  503. </pre></div>
  504. </div>
  505. <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>
  506. <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>
  507. </pre></div>
  508. </div>
  509. </blockquote>
  510. <dl class="method">
  511. <dt id="celery.task.base.TaskSet.join">
  512. <tt class="descname">join</tt><big>(</big><em>timeout=None</em><big>)</big><a class="headerlink" href="#celery.task.base.TaskSet.join" title="Permalink to this definition">¶</a></dt>
  513. <dd><p>Gather the results for all of the tasks in the taskset,
  514. and return a list with them ordered by the order of which they
  515. were called.</p>
  516. <table class="docutils field-list" frame="void" rules="none">
  517. <col class="field-name" />
  518. <col class="field-body" />
  519. <tbody valign="top">
  520. <tr class="field"><th class="field-name">Parameter:</th><td class="field-body"><em>timeout</em> &#8211; The time in seconds, how long
  521. it will wait for results, before the operation times out.</td>
  522. </tr>
  523. <tr class="field"><th class="field-name" colspan="2">Raises TimeoutError:</th></tr>
  524. <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>
  525. and the operation takes longer than <tt class="docutils literal"><span class="pre">timeout</span></tt> seconds.</td>
  526. </tr>
  527. </tbody>
  528. </table>
  529. <p>If any of the tasks raises an exception, the exception
  530. will be reraised by <a title="celery.task.base.TaskSet.join" class="reference internal" href="#celery.task.base.TaskSet.join"><tt class="xref docutils literal"><span class="pre">join()</span></tt></a>.</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">list of return values for all tasks in the taskset.</td>
  536. </tr>
  537. </tbody>
  538. </table>
  539. </dd></dl>
  540. <dl class="classmethod">
  541. <dt id="celery.task.base.TaskSet.map">
  542. <em class="property">
  543. 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.base.TaskSet.map" title="Permalink to this definition">¶</a></dt>
  544. <dd>Distribute processing of the arguments and collect the results.</dd></dl>
  545. <dl class="classmethod">
  546. <dt id="celery.task.base.TaskSet.map_async">
  547. <em class="property">
  548. 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.base.TaskSet.map_async" title="Permalink to this definition">¶</a></dt>
  549. <dd><p>Distribute processing of the arguments and collect the results
  550. asynchronously.</p>
  551. <table class="docutils field-list" frame="void" rules="none">
  552. <col class="field-name" />
  553. <col class="field-body" />
  554. <tbody valign="top">
  555. <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>
  556. </tr>
  557. </tbody>
  558. </table>
  559. </dd></dl>
  560. <dl class="classmethod">
  561. <dt id="celery.task.base.TaskSet.remote_execute">
  562. <em class="property">
  563. classmethod </em><tt class="descname">remote_execute</tt><big>(</big><em>func</em>, <em>args</em><big>)</big><a class="headerlink" href="#celery.task.base.TaskSet.remote_execute" title="Permalink to this definition">¶</a></dt>
  564. <dd>Apply <tt class="docutils literal"><span class="pre">args</span></tt> to function by distributing the args to the
  565. celery server(s).</dd></dl>
  566. <dl class="method">
  567. <dt id="celery.task.base.TaskSet.run">
  568. <tt class="descname">run</tt><big>(</big><em>connect_timeout=4</em><big>)</big><a class="headerlink" href="#celery.task.base.TaskSet.run" title="Permalink to this definition">¶</a></dt>
  569. <dd><p>Run all tasks in the taskset.</p>
  570. <table class="docutils field-list" frame="void" rules="none">
  571. <col class="field-name" />
  572. <col class="field-body" />
  573. <tbody valign="top">
  574. <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>
  575. </tr>
  576. </tbody>
  577. </table>
  578. <p>Example</p>
  579. <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>
  580. <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>
  581. <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>
  582. <span class="gp">... </span><span class="p">)</span>
  583. <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>
  584. <span class="gp">&gt;&gt;&gt; </span><span class="n">result</span><span class="o">.</span><span class="n">taskset_id</span>
  585. <span class="go">&quot;d2c9b261-8eff-4bfb-8459-1e1b72063514&quot;</span>
  586. <span class="gp">&gt;&gt;&gt; </span><span class="n">result</span><span class="o">.</span><span class="n">subtask_ids</span>
  587. <span class="go">[&quot;b4996460-d959-49c8-aeb9-39c530dcde25&quot;,</span>
  588. <span class="go">&quot;598d2d18-ab86-45ca-8b4f-0779f5d6a3cb&quot;]</span>
  589. <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>
  590. <span class="go">True</span>
  591. <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>
  592. <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>
  593. <span class="go">True</span>
  594. <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>
  595. <span class="go">True</span>
  596. <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>
  597. <span class="go">False</span>
  598. <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>
  599. <span class="go">[True, True]</span>
  600. </pre></div>
  601. </div>
  602. </dd></dl>
  603. </dd></dl>
  604. </div>
  605. </div>
  606. </div>
  607. </div>
  608. <div class="sphinxsidebar">
  609. <div class="sphinxsidebarwrapper">
  610. <h4>Previous topic</h4>
  611. <p class="topless"><a href="index.html"
  612. title="previous chapter">Module API Reference</a></p>
  613. <h4>Next topic</h4>
  614. <p class="topless"><a href="celery.execute.html"
  615. title="next chapter">Executing Tasks - celery.execute</a></p>
  616. <h3>This Page</h3>
  617. <ul class="this-page-menu">
  618. <li><a href="../sources/reference/celery.task.base.txt"
  619. rel="nofollow">Show Source</a></li>
  620. </ul>
  621. <div id="searchbox" style="display: none">
  622. <h3>Quick search</h3>
  623. <form class="search" action="../search.html" method="get">
  624. <input type="text" name="q" size="18" />
  625. <input type="submit" value="Go" />
  626. <input type="hidden" name="check_keywords" value="yes" />
  627. <input type="hidden" name="area" value="default" />
  628. </form>
  629. <p class="searchtip" style="font-size: 90%">
  630. Enter search terms or a module, class or function name.
  631. </p>
  632. </div>
  633. <script type="text/javascript">$('#searchbox').show(0);</script>
  634. </div>
  635. </div>
  636. <div class="clearer"></div>
  637. </div>
  638. <div class="related">
  639. <h3>Navigation</h3>
  640. <ul>
  641. <li class="right" style="margin-right: 10px">
  642. <a href="../genindex.html" title="General Index"
  643. >index</a></li>
  644. <li class="right" >
  645. <a href="../modindex.html" title="Global Module Index"
  646. >modules</a> |</li>
  647. <li class="right" >
  648. <a href="celery.execute.html" title="Executing Tasks - celery.execute"
  649. >next</a> |</li>
  650. <li class="right" >
  651. <a href="index.html" title="Module API Reference"
  652. >previous</a> |</li>
  653. <li><a href="../index.html">Celery v0.7.0 (unstable) documentation</a> &raquo;</li>
  654. <li><a href="index.html" >Module API Reference</a> &raquo;</li>
  655. </ul>
  656. </div>
  657. <div class="footer">
  658. &copy; Copyright 2009, Ask Solem.
  659. Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 0.6.2.
  660. </div>
  661. </body>
  662. </html>