forked from celery/celery
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcelery.app.task.html
859 lines (792 loc) · 53.4 KB
/
celery.app.task.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>celery.app.task — Celery 2.6.0a3 documentation</title>
<link rel="stylesheet" href="../_static/celery.css" type="text/css" />
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="../_static/issuetracker.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '../',
VERSION: '2.6.0a3',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="../_static/jquery.js"></script>
<script type="text/javascript" src="../_static/underscore.js"></script>
<script type="text/javascript" src="../_static/doctools.js"></script>
<link rel="top" title="Celery 2.6.0a3 documentation" href="../index.html" />
<link rel="up" title="API Reference" href="index.html" />
<link rel="next" title="celery.app.amqp" href="celery.app.amqp.html" />
<link rel="prev" title="celery.app" href="celery.app.html" />
</head>
<body>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="../py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="right" >
<a href="celery.app.amqp.html" title="celery.app.amqp"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="celery.app.html" title="celery.app"
accesskey="P">previous</a> |</li>
<li><a href="../index.html">Celery 2.6.0a3 documentation</a> »</li>
<li><a href="index.html" accesskey="U">API Reference</a> »</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body">
<div class="deck">
<p class="developmentversion">
This document is for Celery's development version, which can be
significantly different from previous releases. Get old docs here:
<a href="http://docs.celeryproject.org/en/latest/reference/celery.app.task.html">2.5</a>.
</p>
</div>
<div class="section" id="celery-app-task">
<h1>celery.app.task<a class="headerlink" href="#celery-app-task" title="Permalink to this headline">¶</a></h1>
<div class="contents local topic" id="contents">
<ul class="simple">
<li><a class="reference internal" href="#id1" id="id2">celery.app.task</a></li>
</ul>
</div>
<span class="target" id="module-celery.app.task"></span><div class="section" id="id1">
<h2><a class="toc-backref" href="#id2">celery.app.task</a><a class="headerlink" href="#id1" title="Permalink to this headline">¶</a></h2>
<p>Tasks Implementation.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">copyright:</th><td class="field-body"><ol class="first loweralpha simple" start="3">
<li>2009 - 2012 by Ask Solem.</li>
</ol>
</td>
</tr>
<tr class="field-even field"><th class="field-name">license:</th><td class="field-body"><p class="first last">BSD, see LICENSE for more details.</p>
</td>
</tr>
</tbody>
</table>
<dl class="class">
<dt id="celery.app.task.TaskType">
<em class="property">class </em><tt class="descclassname">celery.app.task.</tt><tt class="descname">TaskType</tt><a class="headerlink" href="#celery.app.task.TaskType" title="Permalink to this definition">¶</a></dt>
<dd><p>Meta class for tasks.</p>
<p>Automatically registers the task in the task registry, except
if the <cite>abstract</cite> attribute is set.</p>
<p>If no <cite>name</cite> attribute is provided, then no name is automatically
set to the name of the module it was defined in, and the class name.</p>
</dd></dl>
<dl class="class">
<dt id="celery.app.task.BaseTask">
<em class="property">class </em><tt class="descclassname">celery.app.task.</tt><tt class="descname">BaseTask</tt><a class="headerlink" href="#celery.app.task.BaseTask" title="Permalink to this definition">¶</a></dt>
<dd><p>Task base class.</p>
<p>When called tasks apply the <a class="reference internal" href="#celery.app.task.BaseTask.run" title="celery.app.task.BaseTask.run"><tt class="xref py py-meth docutils literal"><span class="pre">run()</span></tt></a> method. This method must
be defined by all tasks (that is unless the <tt class="xref py py-meth docutils literal"><span class="pre">__call__()</span></tt> method
is overridden).</p>
<dl class="method">
<dt id="celery.app.task.BaseTask.AsyncResult">
<tt class="descname">AsyncResult</tt><big>(</big><em>task_id</em><big>)</big><a class="headerlink" href="#celery.app.task.BaseTask.AsyncResult" title="Permalink to this definition">¶</a></dt>
<dd><p>Get AsyncResult instance for this kind of task.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>task_id</strong> – Task id to get result for.</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="class">
<dt id="celery.app.task.BaseTask.ErrorMail">
<em class="property">class </em><tt class="descname">ErrorMail</tt><big>(</big><em>task</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#celery.app.task.BaseTask.ErrorMail" title="Permalink to this definition">¶</a></dt>
<dd><p>Defines how and when task error e-mails should be sent.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>task</strong> – The task instance that raised the error.</td>
</tr>
</tbody>
</table>
<p><tt class="xref py py-attr docutils literal"><span class="pre">subject</span></tt> and <tt class="xref py py-attr docutils literal"><span class="pre">body</span></tt> are format strings which
are passed a context containing the following keys:</p>
<ul>
<li><p class="first">name</p>
<blockquote>
<div><p>Name of the task.</p>
</div></blockquote>
</li>
<li><p class="first">id</p>
<blockquote>
<div><p>UUID of the task.</p>
</div></blockquote>
</li>
<li><p class="first">exc</p>
<blockquote>
<div><p>String representation of the exception.</p>
</div></blockquote>
</li>
<li><p class="first">args</p>
<blockquote>
<div><p>Positional arguments.</p>
</div></blockquote>
</li>
<li><p class="first">kwargs</p>
<blockquote>
<div><p>Keyword arguments.</p>
</div></blockquote>
</li>
<li><p class="first">traceback</p>
<blockquote>
<div><p>String representation of the traceback.</p>
</div></blockquote>
</li>
<li><p class="first">hostname</p>
<blockquote>
<div><p>Worker hostname.</p>
</div></blockquote>
</li>
</ul>
<dl class="method">
<dt id="celery.app.task.BaseTask.ErrorMail.should_send">
<tt class="descname">should_send</tt><big>(</big><em>context</em>, <em>exc</em><big>)</big><a class="headerlink" href="#celery.app.task.BaseTask.ErrorMail.should_send" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns true or false depending on if a task error mail
should be sent for this type of error.</p>
</dd></dl>
</dd></dl>
<dl class="exception">
<dt id="celery.app.task.BaseTask.MaxRetriesExceededError">
<em class="property">exception </em><tt class="descclassname">BaseTask.</tt><tt class="descname">MaxRetriesExceededError</tt><a class="headerlink" href="#celery.app.task.BaseTask.MaxRetriesExceededError" title="Permalink to this definition">¶</a></dt>
<dd><p>The tasks max restart limit has been exceeded.</p>
</dd></dl>
<dl class="attribute">
<dt id="celery.app.task.BaseTask.Strategy">
<tt class="descclassname">BaseTask.</tt><tt class="descname">Strategy</tt><em class="property"> = 'celery.worker.strategy:default'</em><a class="headerlink" href="#celery.app.task.BaseTask.Strategy" title="Permalink to this definition">¶</a></dt>
<dd><p>Execution strategy used, or the qualified name of one.</p>
</dd></dl>
<dl class="attribute">
<dt id="celery.app.task.BaseTask.abstract">
<tt class="descclassname">BaseTask.</tt><tt class="descname">abstract</tt><em class="property"> = None</em><a class="headerlink" href="#celery.app.task.BaseTask.abstract" title="Permalink to this definition">¶</a></dt>
<dd><p>If <tt class="xref py py-const docutils literal"><span class="pre">True</span></tt> the task is an abstract base class.</p>
</dd></dl>
<dl class="attribute">
<dt id="celery.app.task.BaseTask.accept_magic_kwargs">
<tt class="descclassname">BaseTask.</tt><tt class="descname">accept_magic_kwargs</tt><em class="property"> = False</em><a class="headerlink" href="#celery.app.task.BaseTask.accept_magic_kwargs" title="Permalink to this definition">¶</a></dt>
<dd><p>If disabled the worker will not forward magic keyword arguments.
Deprecated and scheduled for removal in v3.0.</p>
</dd></dl>
<dl class="attribute">
<dt id="celery.app.task.BaseTask.acks_late">
<tt class="descclassname">BaseTask.</tt><tt class="descname">acks_late</tt><em class="property"> = False</em><a class="headerlink" href="#celery.app.task.BaseTask.acks_late" title="Permalink to this definition">¶</a></dt>
<dd><p>When enabled messages for this task will be acknowledged <strong>after</strong>
the task has been executed, and not <em>just before</em> which is the
default behavior.</p>
<p>Please note that this means the task may be executed twice if the
worker crashes mid execution (which may be acceptable for some
applications).</p>
<p>The application default can be overridden with the
<a class="reference internal" href="../configuration.html#std:setting-CELERY_ACKS_LATE"><tt class="xref std std-setting docutils literal"><span class="pre">CELERY_ACKS_LATE</span></tt></a> setting.</p>
</dd></dl>
<dl class="method">
<dt id="celery.app.task.BaseTask.after_return">
<tt class="descclassname">BaseTask.</tt><tt class="descname">after_return</tt><big>(</big><em>status</em>, <em>retval</em>, <em>task_id</em>, <em>args</em>, <em>kwargs</em>, <em>einfo</em><big>)</big><a class="headerlink" href="#celery.app.task.BaseTask.after_return" title="Permalink to this definition">¶</a></dt>
<dd><p>Handler called after the task returns.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>status</strong> – Current task state.</li>
<li><strong>retval</strong> – Task return value/exception.</li>
<li><strong>task_id</strong> – Unique id of the task.</li>
<li><strong>args</strong> – Original arguments for the task that failed.</li>
<li><strong>kwargs</strong> – Original keyword arguments for the task
that failed.</li>
<li><strong>einfo</strong> – <a class="reference internal" href="../internals/reference/celery.datastructures.html#celery.datastructures.ExceptionInfo" title="celery.datastructures.ExceptionInfo"><tt class="xref py py-class docutils literal"><span class="pre">ExceptionInfo</span></tt></a>
instance, containing the traceback (if any).</li>
</ul>
</td>
</tr>
</tbody>
</table>
<p>The return value of this handler is ignored.</p>
</dd></dl>
<dl class="method">
<dt id="celery.app.task.BaseTask.apply">
<tt class="descclassname">BaseTask.</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.app.task.BaseTask.apply" title="Permalink to this definition">¶</a></dt>
<dd><p>Execute this task locally, by blocking until the task returns.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>args</strong> – positional arguments passed on to the task.</li>
<li><strong>kwargs</strong> – keyword arguments passed on to the task.</li>
<li><strong>throw</strong> – Re-raise task exceptions. Defaults to
the <a class="reference internal" href="../configuration.html#std:setting-CELERY_EAGER_PROPAGATES_EXCEPTIONS"><tt class="xref std std-setting docutils literal"><span class="pre">CELERY_EAGER_PROPAGATES_EXCEPTIONS</span></tt></a>
setting.</li>
</ul>
</td>
</tr>
</tbody>
</table>
<p>:rtype <a class="reference internal" href="celery.result.html#celery.result.EagerResult" title="celery.result.EagerResult"><tt class="xref py py-class docutils literal"><span class="pre">celery.result.EagerResult</span></tt></a>:</p>
</dd></dl>
<dl class="method">
<dt id="celery.app.task.BaseTask.apply_async">
<tt class="descclassname">BaseTask.</tt><tt class="descname">apply_async</tt><big>(</big><em>args=None</em>, <em>kwargs=None</em>, <em>task_id=None</em>, <em>publisher=None</em>, <em>connection=None</em>, <em>router=None</em>, <em>queues=None</em>, <em>link=None</em>, <em>link_error=None</em>, <em>**options</em><big>)</big><a class="headerlink" href="#celery.app.task.BaseTask.apply_async" title="Permalink to this definition">¶</a></dt>
<dd><p>Apply tasks asynchronously by sending a message.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>args</strong> – The positional arguments to pass on to the
task (a <tt class="xref py py-class docutils literal"><span class="pre">list</span></tt> or <tt class="xref py py-class docutils literal"><span class="pre">tuple</span></tt>).</li>
<li><strong>kwargs</strong> – The keyword arguments to pass on to the
task (a <a class="reference external" href="http://docs.python.org/dev/library/stdtypes.html#dict" title="(in Python v3.3)"><tt class="xref py py-class docutils literal"><span class="pre">dict</span></tt></a>)</li>
<li><strong>countdown</strong> – Number of seconds into the future that the
task should execute. Defaults to immediate
execution (do not confuse with the
<cite>immediate</cite> flag, as they are unrelated).</li>
<li><strong>eta</strong> – A <a class="reference external" href="http://docs.python.org/dev/library/datetime.html#datetime.datetime" title="(in Python v3.3)"><tt class="xref py py-class docutils literal"><span class="pre">datetime</span></tt></a> object describing
the absolute time and date of when the task should
be executed. May not be specified if <cite>countdown</cite>
is also supplied. (Do not confuse this with the
<cite>immediate</cite> flag, as they are unrelated).</li>
<li><strong>expires</strong> – Either a <tt class="xref py py-class docutils literal"><span class="pre">int</span></tt>, describing the number of
seconds, or a <a class="reference external" href="http://docs.python.org/dev/library/datetime.html#datetime.datetime" title="(in Python v3.3)"><tt class="xref py py-class docutils literal"><span class="pre">datetime</span></tt></a> object
that describes the absolute time and date of when
the task should expire. The task will not be
executed after the expiration time.</li>
<li><strong>connection</strong> – Re-use existing broker connection instead
of establishing a new one.</li>
<li><strong>retry</strong> – If enabled sending of the task message will be retried
in the event of connection loss or failure. Default
is taken from the <a class="reference internal" href="../configuration.html#std:setting-CELERY_TASK_PUBLISH_RETRY"><tt class="xref std std-setting docutils literal"><span class="pre">CELERY_TASK_PUBLISH_RETRY</span></tt></a>
setting. Note you need to handle the
publisher/connection manually for this to work.</li>
<li><strong>retry_policy</strong> – Override the retry policy used. See the
<a class="reference internal" href="../configuration.html#std:setting-CELERY_TASK_PUBLISH_RETRY"><tt class="xref std std-setting docutils literal"><span class="pre">CELERY_TASK_PUBLISH_RETRY</span></tt></a> setting.</li>
<li><strong>routing_key</strong> – The routing key used to route the task to a
worker server. Defaults to the
<a class="reference internal" href="#celery.app.task.BaseTask.routing_key" title="celery.app.task.BaseTask.routing_key"><tt class="xref py py-attr docutils literal"><span class="pre">routing_key</span></tt></a> attribute.</li>
<li><strong>exchange</strong> – The named exchange to send the task to.
Defaults to the <a class="reference internal" href="#celery.app.task.BaseTask.exchange" title="celery.app.task.BaseTask.exchange"><tt class="xref py py-attr docutils literal"><span class="pre">exchange</span></tt></a> attribute.</li>
<li><strong>exchange_type</strong> – The exchange type to initialize the exchange
if not already declared. Defaults to the
<a class="reference internal" href="#celery.app.task.BaseTask.exchange_type" title="celery.app.task.BaseTask.exchange_type"><tt class="xref py py-attr docutils literal"><span class="pre">exchange_type</span></tt></a> attribute.</li>
<li><strong>immediate</strong> – Request immediate delivery. Will raise an
exception if the task cannot be routed to a worker
immediately. (Do not confuse this parameter with
the <cite>countdown</cite> and <cite>eta</cite> settings, as they are
unrelated). Defaults to the <a class="reference internal" href="#celery.app.task.BaseTask.immediate" title="celery.app.task.BaseTask.immediate"><tt class="xref py py-attr docutils literal"><span class="pre">immediate</span></tt></a>
attribute.</li>
<li><strong>mandatory</strong> – Mandatory routing. Raises an exception if
there’s no running workers able to take on this
task. Defaults to the <a class="reference internal" href="#celery.app.task.BaseTask.mandatory" title="celery.app.task.BaseTask.mandatory"><tt class="xref py py-attr docutils literal"><span class="pre">mandatory</span></tt></a>
attribute.</li>
<li><strong>priority</strong> – The task priority, a number between 0 and 9.
Defaults to the <a class="reference internal" href="#celery.app.task.BaseTask.priority" title="celery.app.task.BaseTask.priority"><tt class="xref py py-attr docutils literal"><span class="pre">priority</span></tt></a> attribute.</li>
<li><strong>serializer</strong> – A string identifying the default
serialization method to use. Can be <cite>pickle</cite>,
<cite>json</cite>, <cite>yaml</cite>, <cite>msgpack</cite> or any custom
serialization method that has been registered
with <tt class="xref py py-mod docutils literal"><span class="pre">kombu.serialization.registry</span></tt>.
Defaults to the <a class="reference internal" href="#celery.app.task.BaseTask.serializer" title="celery.app.task.BaseTask.serializer"><tt class="xref py py-attr docutils literal"><span class="pre">serializer</span></tt></a> attribute.</li>
<li><strong>compression</strong> – A string identifying the compression method
to use. Can be one of <tt class="docutils literal"><span class="pre">zlib</span></tt>, <tt class="docutils literal"><span class="pre">bzip2</span></tt>,
or any custom compression methods registered with
<a class="reference external" href="http://kombu.readthedocs.org/en/latest/reference/kombu.compression.html#kombu.compression.register" title="(in Kombu v2.1)"><tt class="xref py py-func docutils literal"><span class="pre">kombu.compression.register()</span></tt></a>. Defaults to
the <a class="reference internal" href="../configuration.html#std:setting-CELERY_MESSAGE_COMPRESSION"><tt class="xref std std-setting docutils literal"><span class="pre">CELERY_MESSAGE_COMPRESSION</span></tt></a>
setting.</li>
<li><strong>link</strong> – A single, or a list of subtasks to apply if the
task exits successfully.</li>
<li><strong>link_error</strong> – A single, or a list of subtasks to apply
if an error occurs while executing the task.</li>
</ul>
</td>
</tr>
</tbody>
</table>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">If the <a class="reference internal" href="../configuration.html#std:setting-CELERY_ALWAYS_EAGER"><tt class="xref std std-setting docutils literal"><span class="pre">CELERY_ALWAYS_EAGER</span></tt></a> setting is set, it will
be replaced by a local <a class="reference internal" href="#celery.app.task.BaseTask.apply" title="celery.app.task.BaseTask.apply"><tt class="xref py py-func docutils literal"><span class="pre">apply()</span></tt></a> call instead.</p>
</div>
</dd></dl>
<dl class="attribute">
<dt id="celery.app.task.BaseTask.autoregister">
<tt class="descclassname">BaseTask.</tt><tt class="descname">autoregister</tt><em class="property"> = True</em><a class="headerlink" href="#celery.app.task.BaseTask.autoregister" title="Permalink to this definition">¶</a></dt>
<dd><p>If disabled this task won’t be registered automatically.</p>
</dd></dl>
<dl class="attribute">
<dt id="celery.app.task.BaseTask.backend">
<tt class="descclassname">BaseTask.</tt><tt class="descname">backend</tt><em class="property"> = None</em><a class="headerlink" href="#celery.app.task.BaseTask.backend" title="Permalink to this definition">¶</a></dt>
<dd><p>The result store backend used for this task.</p>
</dd></dl>
<dl class="attribute">
<dt id="celery.app.task.BaseTask.default_retry_delay">
<tt class="descclassname">BaseTask.</tt><tt class="descname">default_retry_delay</tt><em class="property"> = 180</em><a class="headerlink" href="#celery.app.task.BaseTask.default_retry_delay" title="Permalink to this definition">¶</a></dt>
<dd><p>Default time in seconds before a retry of the task should be
executed. 3 minutes by default.</p>
</dd></dl>
<dl class="method">
<dt id="celery.app.task.BaseTask.delay">
<tt class="descclassname">BaseTask.</tt><tt class="descname">delay</tt><big>(</big><em>*args</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#celery.app.task.BaseTask.delay" title="Permalink to this definition">¶</a></dt>
<dd><p>Star argument version of <a class="reference internal" href="#celery.app.task.BaseTask.apply_async" title="celery.app.task.BaseTask.apply_async"><tt class="xref py py-meth docutils literal"><span class="pre">apply_async()</span></tt></a>.</p>
<p>Does not support the extra options enabled by <a class="reference internal" href="#celery.app.task.BaseTask.apply_async" title="celery.app.task.BaseTask.apply_async"><tt class="xref py py-meth docutils literal"><span class="pre">apply_async()</span></tt></a>.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>*args</strong> – positional arguments passed on to the task.</li>
<li><strong>**kwargs</strong> – keyword arguments passed on to the task.</li>
</ul>
</td>
</tr>
</tbody>
</table>
<p>:returns <a class="reference internal" href="celery.result.html#celery.result.AsyncResult" title="celery.result.AsyncResult"><tt class="xref py py-class docutils literal"><span class="pre">celery.result.AsyncResult</span></tt></a>:</p>
</dd></dl>
<dl class="attribute">
<dt id="celery.app.task.BaseTask.delivery_mode">
<tt class="descclassname">BaseTask.</tt><tt class="descname">delivery_mode</tt><em class="property"> = None</em><a class="headerlink" href="#celery.app.task.BaseTask.delivery_mode" title="Permalink to this definition">¶</a></dt>
<dd><p>Override the apps default delivery mode for this task. Default is
<cite>“persistent”</cite>, but you can change this to <cite>“transient”</cite>, which means
messages will be lost if the broker is restarted. Consult your broker
manual for any additional delivery modes.</p>
</dd></dl>
<dl class="attribute">
<dt id="celery.app.task.BaseTask.error_whitelist">
<tt class="descclassname">BaseTask.</tt><tt class="descname">error_whitelist</tt><em class="property"> = ()</em><a class="headerlink" href="#celery.app.task.BaseTask.error_whitelist" title="Permalink to this definition">¶</a></dt>
<dd><p>List of exception types to send error emails for.</p>
</dd></dl>
<dl class="method">
<dt id="celery.app.task.BaseTask.establish_connection">
<tt class="descclassname">BaseTask.</tt><tt class="descname">establish_connection</tt><big>(</big><em>connect_timeout=None</em><big>)</big><a class="headerlink" href="#celery.app.task.BaseTask.establish_connection" title="Permalink to this definition">¶</a></dt>
<dd><p>Establish a connection to the message broker.</p>
</dd></dl>
<dl class="attribute">
<dt id="celery.app.task.BaseTask.exchange">
<tt class="descclassname">BaseTask.</tt><tt class="descname">exchange</tt><em class="property"> = None</em><a class="headerlink" href="#celery.app.task.BaseTask.exchange" title="Permalink to this definition">¶</a></dt>
<dd><p>Overrides the apps default <cite>exchange</cite> for this task.</p>
</dd></dl>
<dl class="attribute">
<dt id="celery.app.task.BaseTask.exchange_type">
<tt class="descclassname">BaseTask.</tt><tt class="descname">exchange_type</tt><em class="property"> = None</em><a class="headerlink" href="#celery.app.task.BaseTask.exchange_type" title="Permalink to this definition">¶</a></dt>
<dd><p>Overrides the apps default exchange type for this task.</p>
</dd></dl>
<dl class="method">
<dt id="celery.app.task.BaseTask.execute">
<tt class="descclassname">BaseTask.</tt><tt class="descname">execute</tt><big>(</big><em>request</em>, <em>pool</em>, <em>loglevel</em>, <em>logfile</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#celery.app.task.BaseTask.execute" title="Permalink to this definition">¶</a></dt>
<dd><p>The method the worker calls to execute the task.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>request</strong> – A <a class="reference internal" href="../internals/reference/celery.worker.job.html#celery.worker.job.Request" title="celery.worker.job.Request"><tt class="xref py py-class docutils literal"><span class="pre">Request</span></tt></a>.</li>
<li><strong>pool</strong> – A task pool.</li>
<li><strong>loglevel</strong> – Current loglevel.</li>
<li><strong>logfile</strong> – Name of the currently used logfile.</li>
<li><strong>consumer</strong> – The <a class="reference internal" href="../internals/reference/celery.worker.consumer.html#celery.worker.consumer.Consumer" title="celery.worker.consumer.Consumer"><tt class="xref py py-class docutils literal"><span class="pre">Consumer</span></tt></a>.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="attribute">
<dt id="celery.app.task.BaseTask.expires">
<tt class="descclassname">BaseTask.</tt><tt class="descname">expires</tt><em class="property"> = None</em><a class="headerlink" href="#celery.app.task.BaseTask.expires" title="Permalink to this definition">¶</a></dt>
<dd><p>Default task expiry time.</p>
</dd></dl>
<dl class="method">
<dt id="celery.app.task.BaseTask.get_consumer">
<tt class="descclassname">BaseTask.</tt><tt class="descname">get_consumer</tt><big>(</big><em>connection=None</em>, <em>connect_timeout=None</em><big>)</big><a class="headerlink" href="#celery.app.task.BaseTask.get_consumer" title="Permalink to this definition">¶</a></dt>
<dd><p>Get message consumer.</p>
<p>:rtype <a class="reference external" href="http://kombu.readthedocs.org/en/latest/reference/kombu.messaging.html#kombu.messaging.Consumer" title="(in Kombu v2.1)"><tt class="xref py py-class docutils literal"><span class="pre">kombu.messaging.Consumer</span></tt></a>:</p>
<div class="admonition warning">
<p class="first admonition-title">Warning</p>
<p>If you don’t specify a connection, one will automatically
be established for you, in that case you need to close this
connection after use:</p>
<div class="last highlight-python"><div class="highlight"><pre><span class="gp">>>> </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>
<span class="gp">>>> </span><span class="c"># do something with consumer</span>
<span class="gp">>>> </span><span class="n">consumer</span><span class="o">.</span><span class="n">close</span><span class="p">()</span>
<span class="gp">>>> </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>
</pre></div>
</div>
</div>
</dd></dl>
<dl class="method">
<dt id="celery.app.task.BaseTask.get_logger">
<tt class="descclassname">BaseTask.</tt><tt class="descname">get_logger</tt><big>(</big><em>**kwargs</em><big>)</big><a class="headerlink" href="#celery.app.task.BaseTask.get_logger" title="Permalink to this definition">¶</a></dt>
<dd><p>Get task-aware logger object.</p>
</dd></dl>
<dl class="method">
<dt id="celery.app.task.BaseTask.get_publisher">
<tt class="descclassname">BaseTask.</tt><tt class="descname">get_publisher</tt><big>(</big><em>connection=None</em>, <em>exchange=None</em>, <em>connect_timeout=None</em>, <em>exchange_type=None</em>, <em>**options</em><big>)</big><a class="headerlink" href="#celery.app.task.BaseTask.get_publisher" title="Permalink to this definition">¶</a></dt>
<dd><p>Get a celery task message publisher.</p>
<p>:rtype <a class="reference internal" href="celery.app.amqp.html#celery.app.amqp.TaskPublisher" title="celery.app.amqp.TaskPublisher"><tt class="xref py py-class docutils literal"><span class="pre">TaskPublisher</span></tt></a>:</p>
<div class="admonition warning">
<p class="first admonition-title">Warning</p>
<p>If you don’t specify a connection, one will automatically
be established for you, in that case you need to close this
connection after use:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">>>> </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>
<span class="gp">>>> </span><span class="c"># ... do something with publisher</span>
<span class="gp">>>> </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>
</pre></div>
</div>
<p>or used as a context:</p>
<div class="last highlight-python"><div class="highlight"><pre><span class="gp">>>> </span><span class="k">with</span> <span class="bp">self</span><span class="o">.</span><span class="n">get_publisher</span><span class="p">()</span> <span class="k">as</span> <span class="n">publisher</span><span class="p">:</span>
<span class="gp">... </span> <span class="c"># ... do something with publisher</span>
</pre></div>
</div>
</div>
</dd></dl>
<dl class="attribute">
<dt id="celery.app.task.BaseTask.ignore_result">
<tt class="descclassname">BaseTask.</tt><tt class="descname">ignore_result</tt><em class="property"> = False</em><a class="headerlink" href="#celery.app.task.BaseTask.ignore_result" title="Permalink to this definition">¶</a></dt>
<dd><p>If enabled the worker will not store task state and return values
for this task. Defaults to the <a class="reference internal" href="../configuration.html#std:setting-CELERY_IGNORE_RESULT"><tt class="xref std std-setting docutils literal"><span class="pre">CELERY_IGNORE_RESULT</span></tt></a>
setting.</p>
</dd></dl>
<dl class="attribute">
<dt id="celery.app.task.BaseTask.immediate">
<tt class="descclassname">BaseTask.</tt><tt class="descname">immediate</tt><em class="property"> = False</em><a class="headerlink" href="#celery.app.task.BaseTask.immediate" title="Permalink to this definition">¶</a></dt>
<dd><p>Request immediate delivery.</p>
</dd></dl>
<dl class="attribute">
<dt id="celery.app.task.BaseTask.mandatory">
<tt class="descclassname">BaseTask.</tt><tt class="descname">mandatory</tt><em class="property"> = False</em><a class="headerlink" href="#celery.app.task.BaseTask.mandatory" title="Permalink to this definition">¶</a></dt>
<dd><p>Mandatory message routing.</p>
</dd></dl>
<dl class="attribute">
<dt id="celery.app.task.BaseTask.max_retries">
<tt class="descclassname">BaseTask.</tt><tt class="descname">max_retries</tt><em class="property"> = 3</em><a class="headerlink" href="#celery.app.task.BaseTask.max_retries" title="Permalink to this definition">¶</a></dt>
<dd><p>Maximum number of retries before giving up. If set to <tt class="xref py py-const docutils literal"><span class="pre">None</span></tt>,
it will <strong>never</strong> stop retrying.</p>
</dd></dl>
<dl class="attribute">
<dt id="celery.app.task.BaseTask.name">
<tt class="descclassname">BaseTask.</tt><tt class="descname">name</tt><em class="property"> = None</em><a class="headerlink" href="#celery.app.task.BaseTask.name" title="Permalink to this definition">¶</a></dt>
<dd><p>Name of the task.</p>
</dd></dl>
<dl class="method">
<dt id="celery.app.task.BaseTask.on_bound">
<tt class="descclassname">BaseTask.</tt><tt class="descname">on_bound</tt><big>(</big><em>app</em><big>)</big><a class="headerlink" href="#celery.app.task.BaseTask.on_bound" title="Permalink to this definition">¶</a></dt>
<dd><p>This method can be defined to do additional actions when the
task class is bound to an app.</p>
</dd></dl>
<dl class="method">
<dt id="celery.app.task.BaseTask.on_failure">
<tt class="descclassname">BaseTask.</tt><tt class="descname">on_failure</tt><big>(</big><em>exc</em>, <em>task_id</em>, <em>args</em>, <em>kwargs</em>, <em>einfo</em><big>)</big><a class="headerlink" href="#celery.app.task.BaseTask.on_failure" title="Permalink to this definition">¶</a></dt>
<dd><p>Error handler.</p>
<p>This is run by the worker when the task fails.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>exc</strong> – The exception raised by the task.</li>
<li><strong>task_id</strong> – Unique id of the failed task.</li>
<li><strong>args</strong> – Original arguments for the task that failed.</li>
<li><strong>kwargs</strong> – Original keyword arguments for the task
that failed.</li>
<li><strong>einfo</strong> – <a class="reference internal" href="../internals/reference/celery.datastructures.html#celery.datastructures.ExceptionInfo" title="celery.datastructures.ExceptionInfo"><tt class="xref py py-class docutils literal"><span class="pre">ExceptionInfo</span></tt></a>
instance, containing the traceback.</li>
</ul>
</td>
</tr>
</tbody>
</table>
<p>The return value of this handler is ignored.</p>
</dd></dl>
<dl class="method">
<dt id="celery.app.task.BaseTask.on_retry">
<tt class="descclassname">BaseTask.</tt><tt class="descname">on_retry</tt><big>(</big><em>exc</em>, <em>task_id</em>, <em>args</em>, <em>kwargs</em>, <em>einfo</em><big>)</big><a class="headerlink" href="#celery.app.task.BaseTask.on_retry" title="Permalink to this definition">¶</a></dt>
<dd><p>Retry handler.</p>
<p>This is run by the worker when the task is to be retried.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>exc</strong> – The exception sent to <a class="reference internal" href="#celery.app.task.BaseTask.retry" title="celery.app.task.BaseTask.retry"><tt class="xref py py-meth docutils literal"><span class="pre">retry()</span></tt></a>.</li>
<li><strong>task_id</strong> – Unique id of the retried task.</li>
<li><strong>args</strong> – Original arguments for the retried task.</li>
<li><strong>kwargs</strong> – Original keyword arguments for the retried task.</li>
<li><strong>einfo</strong> – <a class="reference internal" href="../internals/reference/celery.datastructures.html#celery.datastructures.ExceptionInfo" title="celery.datastructures.ExceptionInfo"><tt class="xref py py-class docutils literal"><span class="pre">ExceptionInfo</span></tt></a>
instance, containing the traceback.</li>
</ul>
</td>
</tr>
</tbody>
</table>
<p>The return value of this handler is ignored.</p>
</dd></dl>
<dl class="method">
<dt id="celery.app.task.BaseTask.on_success">
<tt class="descclassname">BaseTask.</tt><tt class="descname">on_success</tt><big>(</big><em>retval</em>, <em>task_id</em>, <em>args</em>, <em>kwargs</em><big>)</big><a class="headerlink" href="#celery.app.task.BaseTask.on_success" title="Permalink to this definition">¶</a></dt>
<dd><p>Success handler.</p>
<p>Run by the worker if the task executes successfully.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>retval</strong> – The return value of the task.</li>
<li><strong>task_id</strong> – Unique id of the executed task.</li>
<li><strong>args</strong> – Original arguments for the executed task.</li>
<li><strong>kwargs</strong> – Original keyword arguments for the executed task.</li>
</ul>
</td>
</tr>
</tbody>
</table>
<p>The return value of this handler is ignored.</p>
</dd></dl>
<dl class="attribute">
<dt id="celery.app.task.BaseTask.priority">
<tt class="descclassname">BaseTask.</tt><tt class="descname">priority</tt><em class="property"> = None</em><a class="headerlink" href="#celery.app.task.BaseTask.priority" title="Permalink to this definition">¶</a></dt>
<dd><p>Default message priority. A number between 0 to 9, where 0 is the
highest. Note that RabbitMQ does not support priorities.</p>
</dd></dl>
<dl class="attribute">
<dt id="celery.app.task.BaseTask.queue">
<tt class="descclassname">BaseTask.</tt><tt class="descname">queue</tt><em class="property"> = None</em><a class="headerlink" href="#celery.app.task.BaseTask.queue" title="Permalink to this definition">¶</a></dt>
<dd><p>Destination queue. The queue needs to exist
in <a class="reference internal" href="../configuration.html#std:setting-CELERY_QUEUES"><tt class="xref std std-setting docutils literal"><span class="pre">CELERY_QUEUES</span></tt></a>. The <cite>routing_key</cite>, <cite>exchange</cite> and
<cite>exchange_type</cite> attributes will be ignored if this is set.</p>
</dd></dl>
<dl class="attribute">
<dt id="celery.app.task.BaseTask.rate_limit">
<tt class="descclassname">BaseTask.</tt><tt class="descname">rate_limit</tt><em class="property"> = None</em><a class="headerlink" href="#celery.app.task.BaseTask.rate_limit" title="Permalink to this definition">¶</a></dt>
<dd><p>Rate limit for this task type. Examples: <tt class="xref py py-const docutils literal"><span class="pre">None</span></tt> (no rate
limit), <cite>“100/s”</cite> (hundred tasks a second), <cite>“100/m”</cite> (hundred tasks
a minute),`”100/h”` (hundred tasks an hour)</p>
</dd></dl>
<dl class="attribute">
<dt id="celery.app.task.BaseTask.request">
<tt class="descclassname">BaseTask.</tt><tt class="descname">request</tt><em class="property"> = <Context: {}></em><a class="headerlink" href="#celery.app.task.BaseTask.request" title="Permalink to this definition">¶</a></dt>
<dd><p>Request context (set when task is applied).</p>
</dd></dl>
<dl class="method">
<dt id="celery.app.task.BaseTask.retry">
<tt class="descclassname">BaseTask.</tt><tt class="descname">retry</tt><big>(</big><em>args=None</em>, <em>kwargs=None</em>, <em>exc=None</em>, <em>throw=True</em>, <em>eta=None</em>, <em>countdown=None</em>, <em>max_retries=None</em>, <em>**options</em><big>)</big><a class="headerlink" href="#celery.app.task.BaseTask.retry" title="Permalink to this definition">¶</a></dt>
<dd><p>Retry the task.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>args</strong> – Positional arguments to retry with.</li>
<li><strong>kwargs</strong> – Keyword arguments to retry with.</li>
<li><strong>exc</strong> – Optional exception to raise instead of
<a class="reference internal" href="celery.exceptions.html#celery.exceptions.MaxRetriesExceededError" title="celery.exceptions.MaxRetriesExceededError"><tt class="xref py py-exc docutils literal"><span class="pre">MaxRetriesExceededError</span></tt></a>
when the max restart limit has been exceeded.</li>
<li><strong>countdown</strong> – Time in seconds to delay the retry for.</li>
<li><strong>eta</strong> – Explicit time and date to run the retry at
(must be a <a class="reference external" href="http://docs.python.org/dev/library/datetime.html#datetime.datetime" title="(in Python v3.3)"><tt class="xref py py-class docutils literal"><span class="pre">datetime</span></tt></a> instance).</li>
<li><strong>max_retries</strong> – If set, overrides the default retry limit.</li>
<li><strong>**options</strong> – Any extra options to pass on to
meth:<cite>apply_async</cite>.</li>
<li><strong>throw</strong> – If this is <tt class="xref py py-const docutils literal"><span class="pre">False</span></tt>, do not raise the
<a class="reference internal" href="celery.exceptions.html#celery.exceptions.RetryTaskError" title="celery.exceptions.RetryTaskError"><tt class="xref py py-exc docutils literal"><span class="pre">RetryTaskError</span></tt></a> exception,
that tells the worker to mark the task as being
retried. Note that this means the task will be
marked as failed if the task raises an exception,
or successful if it returns.</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name" colspan="2">Raises <a class="reference internal" href="celery.exceptions.html#celery.exceptions.RetryTaskError" title="celery.exceptions.RetryTaskError">celery.exceptions.RetryTaskError</a>:</th></tr>
<tr class="field-even field"><td> </td><td class="field-body"><p class="first last">To tell the worker that
the task has been re-sent for retry. This always happens,
unless the <cite>throw</cite> keyword argument has been explicitly set
to <tt class="xref py py-const docutils literal"><span class="pre">False</span></tt>, and is considered normal operation.</p>
</td>
</tr>
</tbody>
</table>
<p><strong>Example</strong></p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">>>> </span><span class="nd">@task</span>
<span class="gp">>>> </span><span class="k">def</span> <span class="nf">tweet</span><span class="p">(</span><span class="n">auth</span><span class="p">,</span> <span class="n">message</span><span class="p">):</span>
<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">oauth</span><span class="o">=</span><span class="n">auth</span><span class="p">)</span>
<span class="gp">... </span> <span class="k">try</span><span class="p">:</span>
<span class="gp">... </span> <span class="n">twitter</span><span class="o">.</span><span class="n">post_status_update</span><span class="p">(</span><span class="n">message</span><span class="p">)</span>
<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>
<span class="gp">... </span> <span class="c"># Retry in 5 minutes.</span>
<span class="gp">... </span> <span class="k">return</span> <span class="n">tweet</span><span class="o">.</span><span class="n">retry</span><span class="p">(</span><span class="n">countdown</span><span class="o">=</span><span class="mi">60</span> <span class="o">*</span> <span class="mi">5</span><span class="p">,</span> <span class="n">exc</span><span class="o">=</span><span class="n">exc</span><span class="p">)</span>
</pre></div>
</div>
<p>Although the task will never return above as <cite>retry</cite> raises an
exception to notify the worker, we use <cite>return</cite> in front of the retry
to convey that the rest of the block will not be executed.</p>
</dd></dl>
<dl class="attribute">
<dt id="celery.app.task.BaseTask.routing_key">
<tt class="descclassname">BaseTask.</tt><tt class="descname">routing_key</tt><em class="property"> = None</em><a class="headerlink" href="#celery.app.task.BaseTask.routing_key" title="Permalink to this definition">¶</a></dt>
<dd><p>Overrides the apps default <cite>routing_key</cite> for this task.</p>
</dd></dl>
<dl class="method">
<dt id="celery.app.task.BaseTask.run">
<tt class="descclassname">BaseTask.</tt><tt class="descname">run</tt><big>(</big><em>*args</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#celery.app.task.BaseTask.run" title="Permalink to this definition">¶</a></dt>
<dd><p>The body of the task executed by workers.</p>
</dd></dl>
<dl class="method">
<dt id="celery.app.task.BaseTask.s">
<tt class="descclassname">BaseTask.</tt><tt class="descname">s</tt><big>(</big><em>*args</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#celery.app.task.BaseTask.s" title="Permalink to this definition">¶</a></dt>
<dd><p><tt class="docutils literal"><span class="pre">.s(*a,</span> <span class="pre">**k)</span> <span class="pre">-></span> <span class="pre">.subtask(a,</span> <span class="pre">k)</span></tt></p>
</dd></dl>
<dl class="attribute">
<dt id="celery.app.task.BaseTask.send_error_emails">
<tt class="descclassname">BaseTask.</tt><tt class="descname">send_error_emails</tt><em class="property"> = False</em><a class="headerlink" href="#celery.app.task.BaseTask.send_error_emails" title="Permalink to this definition">¶</a></dt>
<dd><p>If enabled an email will be sent to <a class="reference internal" href="../configuration.html#std:setting-ADMINS"><tt class="xref std std-setting docutils literal"><span class="pre">ADMINS</span></tt></a> whenever a task
of this type fails.</p>
</dd></dl>
<dl class="attribute">
<dt id="celery.app.task.BaseTask.serializer">
<tt class="descclassname">BaseTask.</tt><tt class="descname">serializer</tt><em class="property"> = 'pickle'</em><a class="headerlink" href="#celery.app.task.BaseTask.serializer" title="Permalink to this definition">¶</a></dt>
<dd><p>The name of a serializer that are registered with
<tt class="xref py py-mod docutils literal"><span class="pre">kombu.serialization.registry</span></tt>. Default is <cite>“pickle”</cite>.</p>
</dd></dl>
<dl class="attribute">
<dt id="celery.app.task.BaseTask.soft_time_limit">
<tt class="descclassname">BaseTask.</tt><tt class="descname">soft_time_limit</tt><em class="property"> = None</em><a class="headerlink" href="#celery.app.task.BaseTask.soft_time_limit" title="Permalink to this definition">¶</a></dt>
<dd><p>Soft time limit.
Defaults to the <tt class="xref std std-setting docutils literal"><span class="pre">CELERY_TASK_SOFT_TIME_LIMIT</span></tt> setting.</p>
</dd></dl>
<dl class="attribute">
<dt id="celery.app.task.BaseTask.store_errors_even_if_ignored">
<tt class="descclassname">BaseTask.</tt><tt class="descname">store_errors_even_if_ignored</tt><em class="property"> = False</em><a class="headerlink" href="#celery.app.task.BaseTask.store_errors_even_if_ignored" title="Permalink to this definition">¶</a></dt>
<dd><p>When enabled errors will be stored even if the task is otherwise
configured to ignore results.</p>
</dd></dl>
<dl class="method">
<dt id="celery.app.task.BaseTask.subtask">
<tt class="descclassname">BaseTask.</tt><tt class="descname">subtask</tt><big>(</big><em>*args</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#celery.app.task.BaseTask.subtask" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns <tt class="xref py py-class docutils literal"><span class="pre">subtask</span></tt> object for
this task, wrapping arguments and execution options
for a single task invocation.</p>
</dd></dl>
<dl class="attribute">
<dt id="celery.app.task.BaseTask.time_limit">
<tt class="descclassname">BaseTask.</tt><tt class="descname">time_limit</tt><em class="property"> = None</em><a class="headerlink" href="#celery.app.task.BaseTask.time_limit" title="Permalink to this definition">¶</a></dt>
<dd><p>Hard time limit.
Defaults to the <tt class="xref std std-setting docutils literal"><span class="pre">CELERY_TASK_TIME_LIMIT</span></tt> setting.</p>
</dd></dl>
<dl class="attribute">
<dt id="celery.app.task.BaseTask.track_started">
<tt class="descclassname">BaseTask.</tt><tt class="descname">track_started</tt><em class="property"> = False</em><a class="headerlink" href="#celery.app.task.BaseTask.track_started" title="Permalink to this definition">¶</a></dt>
<dd><p>If enabled the task will report its status as “started” when the task
is executed by a worker. Disabled by default as the normal behaviour
is to not report that level of granularity. Tasks are either pending,
finished, or waiting to be retried.</p>
<p>Having a “started” status can be useful for when there are long
running tasks and there is a need to report which task is currently
running.</p>
<p>The application default can be overridden using the
<a class="reference internal" href="../configuration.html#std:setting-CELERY_TRACK_STARTED"><tt class="xref std std-setting docutils literal"><span class="pre">CELERY_TRACK_STARTED</span></tt></a> setting.</p>
</dd></dl>
<dl class="attribute">
<dt id="celery.app.task.BaseTask.type">
<tt class="descclassname">BaseTask.</tt><tt class="descname">type</tt><em class="property"> = 'regular'</em><a class="headerlink" href="#celery.app.task.BaseTask.type" title="Permalink to this definition">¶</a></dt>
<dd><p>The type of task <em>(no longer used)</em>.</p>
</dd></dl>
<dl class="method">
<dt id="celery.app.task.BaseTask.update_state">
<tt class="descclassname">BaseTask.</tt><tt class="descname">update_state</tt><big>(</big><em>task_id=None</em>, <em>state=None</em>, <em>meta=None</em><big>)</big><a class="headerlink" href="#celery.app.task.BaseTask.update_state" title="Permalink to this definition">¶</a></dt>
<dd><p>Update task state.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>task_id</strong> – Id of the task to update.</li>
<li><strong>state</strong> – New state (<tt class="xref py py-class docutils literal"><span class="pre">str</span></tt>).</li>
<li><strong>meta</strong> – State metadata (<a class="reference external" href="http://docs.python.org/dev/library/stdtypes.html#dict" title="(in Python v3.3)"><tt class="xref py py-class docutils literal"><span class="pre">dict</span></tt></a>).</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
</dd></dl>
</div>
</div>
</div>
</div>
</div>
<div class="sphinxsidebar">
<div class="sphinxsidebarwrapper"><p class="logo"><a href="../index.html">
<img class="logo" src="http://cloud.github.com/downloads/ask/celery/celery_128.png" alt="Logo"/>
</a></p>
<h4>Previous topic</h4>
<p class="topless"><a href="celery.app.html"
title="previous chapter">celery.app</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="celery.app.amqp.html"
title="next chapter">celery.app.amqp</a></p>
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="../_sources/reference/celery.app.task.txt"
rel="nofollow">Show Source</a></li>
</ul>
<div id="searchbox" style="display: none">
<h3>Quick search</h3>
<form class="search" action="../search.html" method="get">
<input type="text" name="q" />
<input type="submit" value="Go" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
<p class="searchtip" style="font-size: 90%">
Enter search terms or a module, class or function name.
</p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="../py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="right" >
<a href="celery.app.amqp.html" title="celery.app.amqp"
>next</a> |</li>
<li class="right" >
<a href="celery.app.html" title="celery.app"
>previous</a> |</li>
<li><a href="../index.html">Celery 2.6.0a3 documentation</a> »</li>
<li><a href="index.html" >API Reference</a> »</li>
</ul>
</div>
<div class="footer">
© Copyright 2009-2012, Ask Solem & Contributors.
</div>
</body>
</html>