forked from celery/celery
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Changelog
2024 lines (1354 loc) · 69.1 KB
/
Changelog
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
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
================
Change history
================
1.2.0 [xxxx-xx-xx xx:xx x.x xxxx]
=================================
Upgrading for Django-users
--------------------------
Django integration has been moved to a separate package: `django-celery`_.
* To upgrade you need to install the `django-celery`_ module and change::
INSTALLED_APPS = "celery"
to::
INSTALLED_APPS = "djcelery"
* The following modules has been moved to `django-celery`_:
===================================== =====================================
**Module name** **Replace with**
===================================== =====================================
``celery.models`` ``djcelery.models``
``celery.managers`` ``djcelery.managers``
``celery.views`` ``djcelery.views``
``celery.urls`` ``djcelery.url``
``celery.management`` ``djcelery.management``
``celery.loaders.djangoapp`` ``djcelery.loaders``
``celery.backends.database`` ``djcelery.backends.database``
``celery.backends.cache`` ``djcelery.backends.cache``
===================================== =====================================
Importing :mod:`djcelery` will automatically setup celery to use the Django
loader by setting the :envvar:`CELERY_LOADER`` environment variable (it won't
change it if it's already defined).
When the Django loader is used, the "database" and "cache" backend aliases
will point to the :mod:`djcelery` backends instead of the built-in backends.
.. _`django-celery`: http://pypi.python.org/pypi/django-celery
Upgrading for others
--------------------
The database backend is now using `SQLAlchemy`_ instead of the Django ORM,
see `Supported Databases`_ for a table of supported databases.
The ``DATABASE_*`` settings has been replaced by a single setting:
``CELERY_RESULT_DBURI``. The value here should be an
`SQLAlchemy Connection String`_, some examples include:
.. code-block:: python
# sqlite (filename)
CELERY_RESULT_DBURI = "sqlite:///celerydb.sqlite"
# mysql
CELERY_RESULT_DBURI = "mysql://scott:tiger@localhost/foo"
# postgresql
CELERY_RESULT_DBURI = "postgresql://scott:tiger@localhost/mydatabase"
# oracle
CELERY_RESULT_DBURI = "oracle://scott:tiger@127.0.0.1:1521/sidname"
See `SQLAlchemy Connection Strings`_ for more information about connection
strings.
To specify additional SQLAlchemy database engine options you can use
the ``CELERY_RESULT_ENGINE_OPTIONS`` setting::
# echo enables verbose logging from SQLAlchemy.
CELERY_RESULT_ENGINE_OPTIONS = {"echo": True}
.. _`SQLAlchemy`:
http://www.sqlalchemy.org
.. _`Supported Databases`:
http://www.sqlalchemy.org/docs/dbengine.html#supported-databases
.. _`SQLAlchemy Connection String`:
http://www.sqlalchemy.org/docs/dbengine.html#create-engine-url-arguments
.. _`SQLAlchemy Connection Strings`:
http://www.sqlalchemy.org/docs/dbengine.html#create-engine-url-arguments
Backward incompatible changes
-----------------------------
* Default (python) loader now prints warning on missing ``celeryconfig.py``
instead of raising :exc:`ImportError`.
celeryd raises :exc:`~celery.exceptions.ImproperlyConfigured` if the configuration
is not set up. This makes it possible to use ``--help`` etc, without having a
working configuration.
Also this makes it possible to use the client side of celery without being
configured::
>>> from carrot.connection import Connection
>>> conn = Connection("localhost", "guest", "guest", "/")
>>> from celery.execute import send_task
>>> r = send_task("celery.ping", args=(), kwargs={}, connection=conn)
>>> from celery.backends.amqp import AMQPBackend
>>> r.backend = AMQPBackend(connection=conn)
>>> r.get()
'pong'
* The following deprecated settings has been removed (as scheduled by
the `deprecation timeline`_):
===================================== =====================================
**Setting name** **Replace with**
===================================== =====================================
``CELERY_AMQP_CONSUMER_QUEUES`` ``CELERY_QUEUES``
``CELERY_AMQP_CONSUMER_QUEUES`` ``CELERY_QUEUES``
``CELERY_AMQP_EXCHANGE`` ``CELERY_DEFAULT_EXCHANGE``
``CELERY_AMQP_EXCHANGE_TYPE`` ``CELERY_DEFAULT_AMQP_EXCHANGE_TYPE``
``CELERY_AMQP_CONSUMER_ROUTING_KEY`` ``CELERY_QUEUES``
``CELERY_AMQP_PUBLISHER_ROUTING_KEY`` ``CELERY_DEFAULT_ROUTING_KEY``
===================================== =====================================
.. _`deprecation timeline`:
http://ask.github.com/celery/internals/deprecation.html
* The ``celery.task.rest`` module has been removed, use :mod:`celery.task.http`
instead (as scheduled by the `deprecation timeline`_).
* It's no longer allowed to skip the class name in loader names.
(as scheduled by the `deprecation timeline`_):
Assuming the implicit ``Loader`` class name is no longer supported,
if you use e.g.::
CELERY_LOADER = "myapp.loaders"
You need to include the loader class name, like this::
CELERY_LOADER = "myapp.loaders.Loader"
News
----
* **celeryev**: Curses Celery Monitor and Event Viewer.
This is a simple monitor allowing you to see what tasks are
executing in real-time and investigate tracebacks and results of ready
tasks. It also enables you to set new rate limits and revoke tasks.
Screenshot:
.. image:: http://celeryproject.org/img/celeryevshotsm.jpg
If you run ``celeryev`` with the ``-d`` switch it will act as an event
dumper, simply dumping the events it receives to standard out::
$ celeryev -d
-> celeryev: starting capture...
casper.local [2010-06-04 10:42:07.020000] heartbeat
casper.local [2010-06-04 10:42:14.750000] task received:
tasks.add(61a68756-27f4-4879-b816-3cf815672b0e) args=[2, 2] kwargs={}
eta=2010-06-04T10:42:16.669290, retries=0
casper.local [2010-06-04 10:42:17.230000] task started
tasks.add(61a68756-27f4-4879-b816-3cf815672b0e) args=[2, 2] kwargs={}
casper.local [2010-06-04 10:42:17.960000] task succeeded:
tasks.add(61a68756-27f4-4879-b816-3cf815672b0e)
args=[2, 2] kwargs={} result=4, runtime=0.782663106918
The fields here are, in order: *sender hostname*, *timestamp*, *event type* and
*additional event fields*.
* :mod:`billiard` has been moved back to the celery repository.
===================================== =====================================
**Module name** **celery equivalent**
===================================== =====================================
``billiard.pool`` ``celery.concurrency.processes.pool``
``billiard.serialization`` ``celery.serialization``
``billiard.utils.functional`` ``celery.utils.functional``
===================================== =====================================
The :mod:`billiard` distribution may be maintained, depending on interest.
* now depends on :mod:`carrot` >= 0.10.5
* now depends on :mod:`pyparsing`
* celeryd: Now waits for available pool processes before applying new
tasks to the pool.
This means it doesn't have to wait for dozens of tasks to finish at shutdown
because it has already applied n prefetched tasks without any pool
processes to immediately accept them.
Some overhead for very short tasks though, then the shutdown probably doesn't
matter either so can disable with::
CELERYD_POOL_PUTLOCKS = False
See http://github.com/ask/celery/issues/closed#issue/122
* Added support for task soft and hard timelimits.
New settings added:
* CELERYD_TASK_TIME_LIMIT
Hard time limit. The worker processing the task will be killed and
replaced with a new one when this is exceeded.
* CELERYD_SOFT_TASK_TIME_LIMIT
Soft time limit. The celery.exceptions.SoftTimeLimitExceeded exception
will be raised when this is exceeded. The task can catch this to
e.g. clean up before the hard time limit comes.
New command line arguments to celeryd added:
``--time-limit`` and ``--soft-time-limit``.
What's left?
This won't work on platforms not supporting signals (and specifically
the ``SIGUSR1`` signal) yet. So an alternative the ability to disable
the feature alltogether on nonconforming platforms must be implemented.
Also when the hard time limit is exceeded, the task result should
be a ``TimeLimitExceeded`` exception.
* celeryd now waits for available pool processes before applying new tasks to the pool.
This means it doesn't have to wait for dozens of tasks to finish at shutdown
because it applied n prefetched tasks at once.
Some overhead for very short tasks though, then the shutdown probably doesn't
matter either so the feature can disable by the ``CELERYD_POOL_PUTLOCKS``
setting::
CELERYD_POOL_PUTLOCKS = False
See http://github.com/ask/celery/issues/#issue/122
* Test suite is now passing without a running broker, using the carrot
in-memory backend.
* Log output is now available in colors.
===================================== =====================================
**Log level** **Color**
===================================== =====================================
``DEBUG`` Blue
``WARNING`` Yellow
``CRITICAL`` Magenta
``ERROR`` Red
===================================== =====================================
This is only enabled when the log output is a tty.
You can explicitly enable/disable this feature using the
``CELERYD_LOG_COLOR`` setting.
* Added support for task router classes (like the django multidb routers)
* New setting: CELERY_ROUTES
This is a single, or a list of routers to traverse when
sending tasks. Dicts in this list converts to a
:class:`celery.routes.MapRoute` instance.
Examples:
>>> CELERY_ROUTES = {"celery.ping": "default",
"mytasks.add": "cpu-bound",
"video.encode": {
"queue": "video",
"exchange": "media"
"routing_key": "media.video.encode"}}
>>> CELERY_ROUTES = ("myapp.tasks.Router",
{"celery.ping": "default})
Where ``myapp.tasks.Router`` could be:
.. code-block:: python
class Router(object):
def route_for_task(self, task, task_id=None, args=None, kwargs=None):
if task == "celery.ping":
return "default"
route_for_task may return a string or a dict. A string then means
it's a queue name in ``CELERY_QUEUES``, a dict means it's a custom route.
When sending tasks, the routers are consulted in order. The first
router that doesn't return ``None`` is the route to use. The message options
is then merged with the found route settings, where the routers settings
have priority.
Example if :func:`~celery.execute.apply_async` has these arguments::
>>> Task.apply_async(immediate=False, exchange="video",
... routing_key="video.compress")
and a router returns::
{"immediate": True,
"exchange": "urgent"}
the final message options will be::
immediate=True, exchange="urgent", routing_key="video.compress"
(and any default message options defined in the
:class:`~celery.task.base.Task` class)
* New Task handler called after the task returns:
:meth:`~celery.task.base.Task.after_return`.
* :class:`~celery.datastructures.ExceptionInfo` now passed to
:meth:`~celery.task.base.Task.on_retry`/
:meth:`~celery.task.base.Task.on_failure` as einfo keyword argument.
* celeryd: Added ``CELERYD_MAX_TASKS_PER_CHILD`` /
:option:`--maxtasksperchild`
Defineds the maximum number of tasks a pool worker can process before
the process is terminated and replaced by a new one.
* Revoked tasks now marked with state ``REVOKED``, and ``result.get()``
will now raise :exc:`~celery.exceptions.TaskRevokedError`.
* :func:`celery.task.control.ping` now works as expected.
* ``apply(throw=True)`` / ``CELERY_EAGER_PROPAGATES_EXCEPTIONS``: Makes eager
execution re-raise task errors.
* New signal: :data:`~celery.signals.worker_process_init`: Sent inside the
pool worker process at init.
* celeryd :option:`-Q` option: Ability to specifiy list of queues to use,
disabling other configured queues.
For example, if ``CELERY_QUEUES`` defines four queues: ``image``, ``video``,
``data`` and ``default``, the following command would make celeryd only
consume from the ``image`` and ``video`` queues::
$ celeryd -Q image,video
* celeryd: New return value for the ``revoke`` control command:
Now returns::
{"ok": "task $id revoked"}
instead of ``True``.
* celeryd: Can now enable/disable events using remote control
Example usage:
>>> from celery.task.control import broadcast
>>> broadcast("enable_events")
>>> broadcast("disable_events")
* celeryd: New option ``--version``: Dump version info and exit.
* :mod:`celeryd-multi <celeryd.bin.celeryd_multi>`: Tool for shell scripts
to start multiple workers.
Some examples::
# Advanced example with 10 workers:
# * Three of the workers processes the images and video queue
# * Two of the workers processes the data queue with loglevel DEBUG
# * the rest processes the default' queue.
$ celeryd-multi start 10 -l INFO -Q:1-3 images,video -Q:4,5:data
-Q default -L:4,5 DEBUG
# get commands to start 10 workers, with 3 processes each
$ celeryd-multi start 3 -c 3
celeryd -n celeryd1.myhost -c 3
celeryd -n celeryd2.myhost -c 3
celeryd- n celeryd3.myhost -c 3
# start 3 named workers
$ celeryd-multi start image video data -c 3
celeryd -n image.myhost -c 3
celeryd -n video.myhost -c 3
celeryd -n data.myhost -c 3
# specify custom hostname
$ celeryd-multi start 2 -n worker.example.com -c 3
celeryd -n celeryd1.worker.example.com -c 3
celeryd -n celeryd2.worker.example.com -c 3
# Additionl options are added to each celeryd',
# but you can also modify the options for ranges of or single workers
# 3 workers: Two with 3 processes, and one with 10 processes.
$ celeryd-multi start 3 -c 3 -c:1 10
celeryd -n celeryd1.myhost -c 10
celeryd -n celeryd2.myhost -c 3
celeryd -n celeryd3.myhost -c 3
# can also specify options for named workers
$ celeryd-multi start image video data -c 3 -c:image 10
celeryd -n image.myhost -c 10
celeryd -n video.myhost -c 3
celeryd -n data.myhost -c 3
# ranges and lists of workers in options is also allowed:
# (-c:1-3 can also be written as -c:1,2,3)
$ celeryd-multi start 5 -c 3 -c:1-3 10
celeryd-multi -n celeryd1.myhost -c 10
celeryd-multi -n celeryd2.myhost -c 10
celeryd-multi -n celeryd3.myhost -c 10
celeryd-multi -n celeryd4.myhost -c 3
celeryd-multi -n celeryd5.myhost -c 3
# lists also works with named workers
$ celeryd-multi start foo bar baz xuzzy -c 3 -c:foo,bar,baz 10
celeryd-multi -n foo.myhost -c 10
celeryd-multi -n bar.myhost -c 10
celeryd-multi -n baz.myhost -c 10
celeryd-multi -n xuzzy.myhost -c 3
1.0.4 [2010-05-31 09:54 A.M CEST]
=================================
Critical
--------
* SIGINT/Ctrl+C killed the pool, abrubtly terminating the currently executing
tasks.
Fixed by making the pool worker processes ignore :const:`SIGINT`.
* Should not close the consumers before the pool is terminated, just cancel the consumers.
Issue #122. http://github.com/ask/celery/issues/issue/122
* Now depends on :mod:`billiard` >= 0.3.1
Changes
-------
* :mod:`celery.contrib.abortable`: Abortable tasks.
Tasks that defines steps of execution, the task can then
be aborted after each step has completed.
* Added required RPM package names under ``[bdist_rpm]`` section, to support building RPMs
from the sources using setup.py
* Running unittests: :envvar:`NOSE_VERBOSE` environment var now enables verbose output from Nose.
* :func:`celery.execute.apply`: Pass logfile/loglevel arguments as task kwargs.
Issue #110 http://github.com/ask/celery/issues/issue/110
* celery.execute.apply: Should return exception, not :class:`~celery.datastructures.ExceptionInfo`
on error.
Issue #111 http://github.com/ask/celery/issues/issue/111
* Added new entries to the :doc:`FAQs <faq>`:
* Should I use retry or acks_late?
* Can I execute a task by name?
1.0.3 [2010-05-15 03:00 P.M CEST]
=================================
Important notes
---------------
* Messages are now acked *just before* the task function is executed.
This is the behavior we've wanted all along, but couldn't have because of
limitations in the multiprocessing module.
The previous behavior was not good, and the situation worsened with the
release of 1.0.1, so this change will definitely improve
reliability, performance and operations in general.
For more information please see http://bit.ly/9hom6T
* Database result backend: result now explicitly sets ``null=True`` as
``django-picklefield`` version 0.1.5 changed the default behavior
right under our noses :(
See: http://bit.ly/d5OwMr
This means those who created their celery tables (via syncdb or
celeryinit) with picklefield versions >= 0.1.5 has to alter their tables to
allow the result field to be ``NULL`` manually.
MySQL::
ALTER TABLE celery_taskmeta MODIFY result TEXT NULL
* Removed ``Task.rate_limit_queue_type``, as it was not really useful
and made it harder to refactor some parts.
* Now depends on carrot >= 0.10.4
* Now depends on billiard >= 0.3.0
News
----
* AMQP backend: Added timeout support for ``result.get()`` /
``result.wait()``.
* New task option: ``Task.acks_late`` (default: ``CELERY_ACKS_LATE``)
Late ack means the task messages will be acknowledged **after** the task
has been executed, not *just before*, which is the default behavior.
Note that this means the tasks may be executed twice if the worker
crashes in the middle of their execution. Not acceptable for most
applications, but desirable for others.
* Added crontab-like scheduling to periodic tasks.
Like a cron job, you can specify units of time of when
you would like the task to execute. While not a full implementation
of cron's features, it should provide a fair degree of common scheduling
needs.
You can specify a minute (0-59), an hour (0-23), and/or a day of the
week (0-6 where 0 is Sunday, or by names: sun, mon, tue, wed, thu, fri,
sat).
Examples:
.. code-block:: python
from celery.task.schedules import crontab
from celery.decorators import periodic_task
@periodic_task(run_every=crontab(hour=7, minute=30))
def every_morning():
print("Runs every morning at 7:30a.m")
@periodic_task(run_every=crontab(hour=7, minute=30, day_of_week="mon"))
def every_monday_morning():
print("Run every monday morning at 7:30a.m")
@periodic_task(run_every=crontab(minutes=30))
def every_hour():
print("Runs every hour on the clock. e.g. 1:30, 2:30, 3:30 etc.")
Note that this a late addition. While we have unittests, due to the
nature of this feature we haven't been able to completely test this
in practice, so consider this experimental.
* ``TaskPool.apply_async``: Now supports the ``accept_callback`` argument.
* ``apply_async``: Now raises :exc:`ValueError` if task args is not a list,
or kwargs is not a tuple (http://github.com/ask/celery/issues/issue/95).
* ``Task.max_retries`` can now be ``None``, which means it will retry forever.
* Celerybeat: Now reuses the same connection when publishing large
sets of tasks.
* Modified the task locking example in the documentation to use
``cache.add`` for atomic locking.
* Added experimental support for a *started* status on tasks.
If ``Task.track_started`` is enabled the task will report its status
as "started" when the task is executed by a worker.
The default value is ``False`` as the normal behaviour is to not
report that level of granularity. Tasks are either pending, finished,
or waiting to be retried. 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.
The global default can be overridden by the ``CELERY_TRACK_STARTED``
setting.
* User Guide: New section ``Tips and Best Practices``.
Contributions welcome!
Remote control commands
-----------------------
* Remote control commands can now send replies back to the caller.
Existing commands has been improved to send replies, and the client
interface in ``celery.task.control`` has new keyword arguments: ``reply``,
``timeout`` and ``limit``. Where reply means it will wait for replies,
timeout is the time in seconds to stop waiting for replies, and limit
is the maximum number of replies to get.
By default, it will wait for as many replies as possible for one second.
* rate_limit(task_name, destination=all, reply=False, timeout=1, limit=0)
Worker returns ``{"ok": message}`` on success,
or ``{"failure": message}`` on failure.
>>> from celery.task.control import rate_limit
>>> rate_limit("tasks.add", "10/s", reply=True)
[{'worker1': {'ok': 'new rate limit set successfully'}},
{'worker2': {'ok': 'new rate limit set successfully'}}]
* ping(destination=all, reply=False, timeout=1, limit=0)
Worker returns the simple message ``"pong"``.
>>> from celery.task.control import ping
>>> ping(reply=True)
[{'worker1': 'pong'},
{'worker2': 'pong'},
* revoke(destination=all, reply=False, timeout=1, limit=0)
Worker simply returns ``True``.
>>> from celery.task.control import revoke
>>> revoke("419e46eb-cf6a-4271-86a8-442b7124132c", reply=True)
[{'worker1': True},
{'worker2'; True}]
* You can now add your own remote control commands!
Remote control commands are functions registered in the command
registry. Registering a command is done using
:meth:`celery.worker.control.Panel.register`:
.. code-block:: python
from celery.task.control import Panel
@Panel.register
def reset_broker_connection(panel, **kwargs):
panel.listener.reset_connection()
return {"ok": "connection re-established"}
With this module imported in the worker, you can launch the command
using ``celery.task.control.broadcast``::
>>> from celery.task.control import broadcast
>>> broadcast("reset_broker_connection", reply=True)
[{'worker1': {'ok': 'connection re-established'},
{'worker2': {'ok': 'connection re-established'}}]
**TIP** You can choose the worker(s) to receive the command
by using the ``destination`` argument::
>>> broadcast("reset_broker_connection", destination=["worker1"])
[{'worker1': {'ok': 'connection re-established'}]
* New remote control command: ``dump_reserved``
Dumps tasks reserved by the worker, waiting to be executed::
>>> from celery.task.control import broadcast
>>> broadcast("dump_reserved", reply=True)
[{'myworker1': [<TaskWrapper ....>]}]
* New remote control command: ``dump_schedule``
Dumps the workers currently registered ETA schedule.
These are tasks with an ``eta`` (or ``countdown``) argument
waiting to be executed by the worker.
>>> from celery.task.control import broadcast
>>> broadcast("dump_schedule", reply=True)
[{'w1': []},
{'w3': []},
{'w2': ['0. 2010-05-12 11:06:00 pri0 <TaskWrapper:
{name:"opalfeeds.tasks.refresh_feed_slice",
id:"95b45760-4e73-4ce8-8eac-f100aa80273a",
args:"(<Feeds freq_max:3600 freq_min:60
start:2184.0 stop:3276.0>,)",
kwargs:"{'page': 2}"}>']},
{'w4': ['0. 2010-05-12 11:00:00 pri0 <TaskWrapper:
{name:"opalfeeds.tasks.refresh_feed_slice",
id:"c053480b-58fb-422f-ae68-8d30a464edfe",
args:"(<Feeds freq_max:3600 freq_min:60
start:1092.0 stop:2184.0>,)",
kwargs:"{\'page\': 1}"}>',
'1. 2010-05-12 11:12:00 pri0 <TaskWrapper:
{name:"opalfeeds.tasks.refresh_feed_slice",
id:"ab8bc59e-6cf8-44b8-88d0-f1af57789758",
args:"(<Feeds freq_max:3600 freq_min:60
start:3276.0 stop:4365>,)",
kwargs:"{\'page\': 3}"}>']}]
Fixes
-----
* Mediator thread no longer blocks for more than 1 second.
With rate limits enabled and when there was a lot of remaining time,
the mediator thread could block shutdown (and potentially block other
jobs from coming in).
* Remote rate limits was not properly applied
(http://github.com/ask/celery/issues/issue/98)
* Now handles exceptions with unicode messages correctly in
``TaskWrapper.on_failure``.
* Database backend: ``TaskMeta.result``: default value should be ``None``
not empty string.
1.0.2 [2010-03-31 12:50 P.M CET]
================================
* Deprecated: ``CELERY_BACKEND``, please use ``CELERY_RESULT_BACKEND``
instead.
* We now use a custom logger in tasks. This logger supports task magic
keyword arguments in formats.
The default format for tasks (``CELERYD_TASK_LOG_FORMAT``) now includes
the id and the name of tasks so the origin of task log messages can
easily be traced.
Example output::
[2010-03-25 13:11:20,317: INFO/PoolWorker-1]
[tasks.add(a6e1c5ad-60d9-42a0-8b24-9e39363125a4)] Hello from add
To revert to the previous behavior you can set::
CELERYD_TASK_LOG_FORMAT = """
[%(asctime)s: %(levelname)s/%(processName)s] %(message)s
""".strip()
* Unittests: Don't disable the django test database teardown,
instead fixed the underlying issue which was caused by modifications
to the ``DATABASE_NAME`` setting (http://github.com/ask/celery/issues/82).
* Django Loader: New config ``CELERY_DB_REUSE_MAX`` (max number of tasks
to reuse the same database connection)
The default is to use a new connection for every task.
We would very much like to reuse the connection, but a safe number of
reuses is not known, and we don't have any way to handle the errors
that might happen, which may even be database dependent.
See: http://bit.ly/94fwdd
* celeryd: The worker components are now configurable: ``CELERYD_POOL``,
``CELERYD_LISTENER``, ``CELERYD_MEDIATOR``, and ``CELERYD_ETA_SCHEDULER``.
The default configuration is as follows:
.. code-block:: python
CELERYD_POOL = "celery.concurrency.processes.TaskPool"
CELERYD_MEDIATOR = "celery.worker.controllers.Mediator"
CELERYD_ETA_SCHEDULER = "celery.worker.controllers.ScheduleController"
CELERYD_LISTENER = "celery.worker.listener.CarrotListener"
The ``CELERYD_POOL`` setting makes it easy to swap out the multiprocessing
pool with a threaded pool, or how about a twisted/eventlet pool?
Consider the competition for the first pool plug-in started!
* Debian init scripts: Use ``-a`` not ``&&``
(http://github.com/ask/celery/issues/82).
* Debian init scripts: Now always preserves ``$CELERYD_OPTS`` from the
``/etc/default/celeryd`` and ``/etc/default/celerybeat``.
* celery.beat.Scheduler: Fixed a bug where the schedule was not properly
flushed to disk if the schedule had not been properly initialized.
* celerybeat: Now syncs the schedule to disk when receiving the ``SIGTERM``
and ``SIGINT`` signals.
* Control commands: Make sure keywords arguments are not in unicode.
* ETA scheduler: Was missing a logger object, so the scheduler crashed
when trying to log that a task had been revoked.
* management.commands.camqadm: Fixed typo ``camqpadm`` -> ``camqadm``
(http://github.com/ask/celery/issues/83).
* PeriodicTask.delta_resolution: Was not working for days and hours, now fixed
by rounding to the nearest day/hour.
* Fixed a potential infinite loop in ``BaseAsyncResult.__eq__``, although
there is no evidence that it has ever been triggered.
* celeryd: Now handles messages with encoding problems by acking them and
emitting an error message.
1.0.1 [2010-02-24 07:05 P.M CET]
================================
* Tasks are now acknowledged early instead of late.
This is done because messages can only be acked within the same
connection channel, so if the connection is lost we would have to refetch
the message again to acknowledge it.
This might or might not affect you, but mostly those running tasks with a
really long execution time are affected, as all tasks that has made it
all the way into the pool needs to be executed before the worker can
safely terminate (this is at most the number of pool workers, multiplied
by the ``CELERYD_PREFETCH_MULTIPLIER`` setting.)
We multiply the prefetch count by default to increase the performance at
times with bursts of tasks with a short execution time. If this doesn't
apply to your use case, you should be able to set the prefetch multiplier
to zero, without sacrificing performance.
Please note that a patch to :mod:`multiprocessing` is currently being
worked on, this patch would enable us to use a better solution, and is
scheduled for inclusion in the ``1.2.0`` release.
* celeryd now shutdowns cleanly when receving the ``TERM`` signal.
* celeryd now does a cold shutdown if the ``INT`` signal is received (Ctrl+C),
this means it tries to terminate as soon as possible.
* Caching of results now moved to the base backend classes, so no need
to implement this functionality in the base classes.
* Caches are now also limited in size, so their memory usage doesn't grow
out of control.
You can set the maximum number of results the cache
can hold using the ``CELERY_MAX_CACHED_RESULTS`` setting (the default
is five thousand results). In addition, you can refetch already retrieved
results using ``backend.reload_task_result`` +
``backend.reload_taskset_result`` (that's for those who want to send
results incrementally).
* ``celeryd`` now works on Windows again.
Note that if running with Django,
you can't use ``project.settings`` as the settings module name, but the
following should work::
$ python manage.py celeryd --settings=settings
* Execution: ``.messaging.TaskPublisher.send_task`` now
incorporates all the functionality apply_async previously did.
Like converting countdowns to eta, so :func:`celery.execute.apply_async` is
now simply a convenient front-end to
:meth:`celery.messaging.TaskPublisher.send_task`, using
the task classes default options.
Also :func:`celery.execute.send_task` has been
introduced, which can apply tasks using just the task name (useful
if the client does not have the destination task in its task registry).
Example:
>>> from celery.execute import send_task
>>> result = send_task("celery.ping", args=[], kwargs={})
>>> result.get()
'pong'
* ``camqadm``: This is a new utility for command line access to the AMQP API.
Excellent for deleting queues/bindings/exchanges, experimentation and
testing::
$ camqadm
1> help
Gives an interactive shell, type ``help`` for a list of commands.
When using Django, use the management command instead::
$ python manage.py camqadm
1> help
* Redis result backend: To conform to recent Redis API changes, the following
settings has been deprecated:
* ``REDIS_TIMEOUT``
* ``REDIS_CONNECT_RETRY``
These will emit a ``DeprecationWarning`` if used.
A ``REDIS_PASSWORD`` setting has been added, so you can use the new
simple authentication mechanism in Redis.
* The redis result backend no longer calls ``SAVE`` when disconnecting,
as this is apparently better handled by Redis itself.
* If ``settings.DEBUG`` is on, celeryd now warns about the possible
memory leak it can result in.
* The ETA scheduler now sleeps at most two seconds between iterations.
* The ETA scheduler now deletes any revoked tasks it might encounter.
As revokes are not yet persistent, this is done to make sure the task
is revoked even though it's currently being hold because its eta is e.g.
a week into the future.
* The ``task_id`` argument is now respected even if the task is executed
eagerly (either using apply, or ``CELERY_ALWAYS_EAGER``).
* The internal queues are now cleared if the connection is reset.
* New magic keyword argument: ``delivery_info``.
Used by retry() to resend the task to its original destination using the same
exchange/routing_key.
* Events: Fields was not passed by ``.send()`` (fixes the uuid keyerrors
in celerymon)
* Added ``--schedule``/``-s`` option to celeryd, so it is possible to
specify a custom schedule filename when using an embedded celerybeat
server (the ``-B``/``--beat``) option.
* Better Python 2.4 compatibility. The test suite now passes.
* task decorators: Now preserve docstring as ``cls.__doc__``, (was previously
copied to ``cls.run.__doc__``)
* The ``testproj`` directory has been renamed to ``tests`` and we're now using
``nose`` + ``django-nose`` for test discovery, and ``unittest2`` for test
cases.
* New pip requirements files available in ``contrib/requirements``.
* TaskPublisher: Declarations are now done once (per process).
* Added ``Task.delivery_mode`` and the ``CELERY_DEFAULT_DELIVERY_MODE``
setting.
These can be used to mark messages non-persistent (i.e. so they are
lost if the broker is restarted).
* Now have our own ``ImproperlyConfigured`` exception, instead of using the
Django one.
* Improvements to the debian init scripts: Shows an error if the program is
not executeable. Does not modify ``CELERYD`` when using django with
virtualenv.
1.0.0 [2010-02-10 04:00 P.M CET]
================================
BACKWARD INCOMPATIBLE CHANGES
-----------------------------
* Celery does not support detaching anymore, so you have to use the tools
available on your platform, or something like supervisord to make
celeryd/celerybeat/celerymon into background processes.
We've had too many problems with celeryd daemonizing itself, so it was
decided it has to be removed. Example startup scripts has been added to
``contrib/``:
* Debian, Ubuntu, (start-stop-daemon)
``contrib/debian/init.d/celeryd``
``contrib/debian/init.d/celerybeat``
* Mac OS X launchd
``contrib/mac/org.celeryq.celeryd.plist``
``contrib/mac/org.celeryq.celerybeat.plist``
``contrib/mac/org.celeryq.celerymon.plist``
* Supervisord (http://supervisord.org)
``contrib/supervisord/supervisord.conf``
In addition to ``--detach``, the following program arguments has been
removed: ``--uid``, ``--gid``, ``--workdir``, ``--chroot``, ``--pidfile``,
``--umask``. All good daemonization tools should support equivalent
functionality, so don't worry.
Also the following configuration keys has been removed:
``CELERYD_PID_FILE``, ``CELERYBEAT_PID_FILE``, ``CELERYMON_PID_FILE``.
* Default celeryd loglevel is now ``WARN``, to enable the previous log level
start celeryd with ``--loglevel=INFO``.
* Tasks are automatically registered.
This means you no longer have to register your tasks manually.
You don't have to change your old code right away, as it doesn't matter if
a task is registered twice.
If you don't want your task to be automatically registered you can set
the ``abstract`` attribute
.. code-block:: python