| 1 |
.. _changelog-2.0: |
| 2 |
|
| 3 |
=============================== |
| 4 |
Change history for Celery 2.0 |
| 5 |
=============================== |
| 6 |
|
| 7 |
.. contents:: |
| 8 |
:local: |
| 9 |
|
| 10 |
.. _version-2.0.3: |
| 11 |
|
| 12 |
2.0.3 |
| 13 |
===== |
| 14 |
:release-date: 2010-08-27 12:00 p.m. CEST |
| 15 |
:release-by: Ask Solem |
| 16 |
|
| 17 |
.. _v203-fixes: |
| 18 |
|
| 19 |
Fixes |
| 20 |
----- |
| 21 |
|
| 22 |
* Worker: Properly handle connection errors happening while |
| 23 |
closing consumers. |
| 24 |
|
| 25 |
* Worker: Events are now buffered if the connection is down, |
| 26 |
then sent when the connection is re-established. |
| 27 |
|
| 28 |
* No longer depends on the :pypi:`mailer` package. |
| 29 |
|
| 30 |
This package had a name space collision with `django-mailer`, |
| 31 |
so its functionality was replaced. |
| 32 |
|
| 33 |
* Redis result backend: Documentation typos: Redis doesn't have |
| 34 |
database names, but database numbers. The default database is now 0. |
| 35 |
|
| 36 |
* :class:`~celery.task.control.inspect`: |
| 37 |
`registered_tasks` was requesting an invalid command because of a typo. |
| 38 |
|
| 39 |
See issue #170. |
| 40 |
|
| 41 |
* :setting:`CELERY_ROUTES`: Values defined in the route should now have |
| 42 |
precedence over values defined in :setting:`CELERY_QUEUES` when merging |
| 43 |
the two. |
| 44 |
|
| 45 |
With the follow settings: |
| 46 |
|
| 47 |
.. code-block:: python |
| 48 |
|
| 49 |
CELERY_QUEUES = {'cpubound': {'exchange': 'cpubound', |
| 50 |
'routing_key': 'cpubound'}} |
| 51 |
|
| 52 |
CELERY_ROUTES = {'tasks.add': {'queue': 'cpubound', |
| 53 |
'routing_key': 'tasks.add', |
| 54 |
'serializer': 'json'}} |
| 55 |
|
| 56 |
The final routing options for `tasks.add` will become: |
| 57 |
|
| 58 |
.. code-block:: python |
| 59 |
|
| 60 |
{'exchange': 'cpubound', |
| 61 |
'routing_key': 'tasks.add', |
| 62 |
'serializer': 'json'} |
| 63 |
|
| 64 |
This wasn't the case before: the values |
| 65 |
in :setting:`CELERY_QUEUES` would take precedence. |
| 66 |
|
| 67 |
* Worker crashed if the value of :setting:`CELERY_TASK_ERROR_WHITELIST` was |
| 68 |
not an iterable |
| 69 |
|
| 70 |
* :func:`~celery.execute.apply`: Make sure `kwargs['task_id']` is |
| 71 |
always set. |
| 72 |
|
| 73 |
* `AsyncResult.traceback`: Now returns :const:`None`, instead of raising |
| 74 |
:exc:`KeyError` if traceback is missing. |
| 75 |
|
| 76 |
* :class:`~celery.task.control.inspect`: Replies didn't work correctly |
| 77 |
if no destination was specified. |
| 78 |
|
| 79 |
* Can now store result/meta-data for custom states. |
| 80 |
|
| 81 |
* Worker: A warning is now emitted if the sending of task error |
| 82 |
emails fails. |
| 83 |
|
| 84 |
* ``celeryev``: Curses monitor no longer crashes if the terminal window |
| 85 |
is resized. |
| 86 |
|
| 87 |
See issue #160. |
| 88 |
|
| 89 |
* Worker: On macOS it isn't possible to run `os.exec*` in a process |
| 90 |
that's threaded. |
| 91 |
|
| 92 |
This breaks the SIGHUP restart handler, |
| 93 |
and is now disabled on macOS, emitting a warning instead. |
| 94 |
|
| 95 |
See issue #152. |
| 96 |
|
| 97 |
* :mod:`celery.execute.trace`: Properly handle `raise(str)`, |
| 98 |
which is still allowed in Python 2.4. |
| 99 |
|
| 100 |
See issue #175. |
| 101 |
|
| 102 |
* Using urllib2 in a periodic task on macOS crashed because |
| 103 |
of the proxy auto detection used in macOS. |
| 104 |
|
| 105 |
This is now fixed by using a workaround. |
| 106 |
See issue #143. |
| 107 |
|
| 108 |
* Debian init-scripts: Commands shouldn't run in a sub shell |
| 109 |
|
| 110 |
See issue #163. |
| 111 |
|
| 112 |
* Debian init-scripts: Use the absolute path of ``celeryd`` program to allow stat |
| 113 |
|
| 114 |
See issue #162. |
| 115 |
|
| 116 |
.. _v203-documentation: |
| 117 |
|
| 118 |
Documentation |
| 119 |
------------- |
| 120 |
|
| 121 |
* getting-started/broker-installation: Fixed typo |
| 122 |
|
| 123 |
`set_permissions ""` -> `set_permissions ".*"`. |
| 124 |
|
| 125 |
* Tasks User Guide: Added section on database transactions. |
| 126 |
|
| 127 |
See issue #169. |
| 128 |
|
| 129 |
* Routing User Guide: Fixed typo `"feed": -> {"queue": "feeds"}`. |
| 130 |
|
| 131 |
See issue #169. |
| 132 |
|
| 133 |
* Documented the default values for the :setting:`CELERYD_CONCURRENCY` |
| 134 |
and :setting:`CELERYD_PREFETCH_MULTIPLIER` settings. |
| 135 |
|
| 136 |
* Tasks User Guide: Fixed typos in the subtask example |
| 137 |
|
| 138 |
* celery.signals: Documented worker_process_init. |
| 139 |
|
| 140 |
* Daemonization cookbook: Need to export DJANGO_SETTINGS_MODULE in |
| 141 |
`/etc/default/celeryd`. |
| 142 |
|
| 143 |
* Added some more FAQs from stack overflow |
| 144 |
|
| 145 |
* Daemonization cookbook: Fixed typo `CELERYD_LOGFILE/CELERYD_PIDFILE` |
| 146 |
|
| 147 |
to `CELERYD_LOG_FILE` / `CELERYD_PID_FILE` |
| 148 |
|
| 149 |
Also added troubleshooting section for the init-scripts. |
| 150 |
|
| 151 |
.. _version-2.0.2: |
| 152 |
|
| 153 |
2.0.2 |
| 154 |
===== |
| 155 |
:release-date: 2010-07-22 11:31 a.m. CEST |
| 156 |
:release-by: Ask Solem |
| 157 |
|
| 158 |
* Routes: When using the dict route syntax, the exchange for a task |
| 159 |
could disappear making the task unroutable. |
| 160 |
|
| 161 |
See issue #158. |
| 162 |
|
| 163 |
* Test suite now passing on Python 2.4 |
| 164 |
|
| 165 |
* No longer have to type `PYTHONPATH=.` to use ``celeryconfig`` in the current |
| 166 |
directory. |
| 167 |
|
| 168 |
This is accomplished by the default loader ensuring that the current |
| 169 |
directory is in `sys.path` when loading the config module. |
| 170 |
`sys.path` is reset to its original state after loading. |
| 171 |
|
| 172 |
Adding the current working directory to `sys.path` without the user |
| 173 |
knowing may be a security issue, as this means someone can drop a Python module in the users |
| 174 |
directory that executes arbitrary commands. This was the original reason |
| 175 |
not to do this, but if done *only when loading the config module*, this |
| 176 |
means that the behavior will only apply to the modules imported in the |
| 177 |
config module, which I think is a good compromise (certainly better than |
| 178 |
just explicitly setting `PYTHONPATH=.` anyway) |
| 179 |
|
| 180 |
* Experimental Cassandra backend added. |
| 181 |
|
| 182 |
* Worker: SIGHUP handler accidentally propagated to worker pool processes. |
| 183 |
|
| 184 |
In combination with :sha:`7a7c44e39344789f11b5346e9cc8340f5fe4846c` |
| 185 |
this would make each child process start a new worker instance when |
| 186 |
the terminal window was closed :/ |
| 187 |
|
| 188 |
* Worker: Don't install SIGHUP handler if running from a terminal. |
| 189 |
|
| 190 |
This fixes the problem where the worker is launched in the background |
| 191 |
when closing the terminal. |
| 192 |
|
| 193 |
* Worker: Now joins threads at shutdown. |
| 194 |
|
| 195 |
See issue #152. |
| 196 |
|
| 197 |
* Test tear down: Don't use `atexit` but nose's `teardown()` functionality |
| 198 |
instead. |
| 199 |
|
| 200 |
See issue #154. |
| 201 |
|
| 202 |
* Debian worker init-script: Stop now works correctly. |
| 203 |
|
| 204 |
* Task logger: `warn` method added (synonym for `warning`) |
| 205 |
|
| 206 |
* Can now define a white list of errors to send error emails for. |
| 207 |
|
| 208 |
Example: |
| 209 |
|
| 210 |
.. code-block:: python |
| 211 |
|
| 212 |
CELERY_TASK_ERROR_WHITELIST = ('myapp.MalformedInputError',) |
| 213 |
|
| 214 |
See issue #153. |
| 215 |
|
| 216 |
* Worker: Now handles overflow exceptions in `time.mktime` while parsing |
| 217 |
the ETA field. |
| 218 |
|
| 219 |
* LoggerWrapper: Try to detect loggers logging back to stderr/stdout making |
| 220 |
an infinite loop. |
| 221 |
|
| 222 |
* Added :class:`celery.task.control.inspect`: Inspects a running worker. |
| 223 |
|
| 224 |
Examples: |
| 225 |
|
| 226 |
.. code-block:: pycon |
| 227 |
|
| 228 |
# Inspect a single worker |
| 229 |
>>> i = inspect('myworker.example.com') |
| 230 |
|
| 231 |
# Inspect several workers |
| 232 |
>>> i = inspect(['myworker.example.com', 'myworker2.example.com']) |
| 233 |
|
| 234 |
# Inspect all workers consuming on this vhost. |
| 235 |
>>> i = inspect() |
| 236 |
|
| 237 |
### Methods |
| 238 |
|
| 239 |
# Get currently executing tasks |
| 240 |
>>> i.active() |
| 241 |
|
| 242 |
# Get currently reserved tasks |
| 243 |
>>> i.reserved() |
| 244 |
|
| 245 |
# Get the current ETA schedule |
| 246 |
>>> i.scheduled() |
| 247 |
|
| 248 |
# Worker statistics and info |
| 249 |
>>> i.stats() |
| 250 |
|
| 251 |
# List of currently revoked tasks |
| 252 |
>>> i.revoked() |
| 253 |
|
| 254 |
# List of registered tasks |
| 255 |
>>> i.registered_tasks() |
| 256 |
|
| 257 |
* Remote control commands `dump_active`/`dump_reserved`/`dump_schedule` |
| 258 |
now replies with detailed task requests. |
| 259 |
|
| 260 |
Containing the original arguments and fields of the task requested. |
| 261 |
|
| 262 |
In addition the remote control command `set_loglevel` has been added, |
| 263 |
this only changes the log level for the main process. |
| 264 |
|
| 265 |
* Worker control command execution now catches errors and returns their |
| 266 |
string representation in the reply. |
| 267 |
|
| 268 |
* Functional test suite added |
| 269 |
|
| 270 |
:mod:`celery.tests.functional.case` contains utilities to start |
| 271 |
and stop an embedded worker process, for use in functional testing. |
| 272 |
|
| 273 |
.. _version-2.0.1: |
| 274 |
|
| 275 |
2.0.1 |
| 276 |
===== |
| 277 |
:release-date: 2010-07-09 03:02 p.m. CEST |
| 278 |
:release-by: Ask Solem |
| 279 |
|
| 280 |
* multiprocessing.pool: Now handles encoding errors, so that pickling errors |
| 281 |
doesn't crash the worker processes. |
| 282 |
|
| 283 |
* The remote control command replies wasn't working with RabbitMQ 1.8.0's |
| 284 |
stricter equivalence checks. |
| 285 |
|
| 286 |
If you've already hit this problem you may have to delete the |
| 287 |
declaration: |
| 288 |
|
| 289 |
.. code-block:: console |
| 290 |
|
| 291 |
$ camqadm exchange.delete celerycrq |
| 292 |
|
| 293 |
or: |
| 294 |
|
| 295 |
.. code-block:: console |
| 296 |
|
| 297 |
$ python manage.py camqadm exchange.delete celerycrq |
| 298 |
|
| 299 |
* A bug sneaked in the ETA scheduler that made it only able to execute |
| 300 |
one task per second(!) |
| 301 |
|
| 302 |
The scheduler sleeps between iterations so it doesn't consume too much CPU. |
| 303 |
It keeps a list of the scheduled items sorted by time, at each iteration |
| 304 |
it sleeps for the remaining time of the item with the nearest deadline. |
| 305 |
If there are no ETA tasks it will sleep for a minimum amount of time, one |
| 306 |
second by default. |
| 307 |
|
| 308 |
A bug sneaked in here, making it sleep for one second for every task |
| 309 |
that was scheduled. This has been fixed, so now it should move |
| 310 |
tasks like hot knife through butter. |
| 311 |
|
| 312 |
In addition a new setting has been added to control the minimum sleep |
| 313 |
interval; :setting:`CELERYD_ETA_SCHEDULER_PRECISION`. A good |
| 314 |
value for this would be a float between 0 and 1, depending |
| 315 |
on the needed precision. A value of 0.8 means that when the ETA of a task |
| 316 |
is met, it will take at most 0.8 seconds for the task to be moved to the |
| 317 |
ready queue. |
| 318 |
|
| 319 |
* Pool: Supervisor didn't release the semaphore. |
| 320 |
|
| 321 |
This would lead to a deadlock if all workers terminated prematurely. |
| 322 |
|
| 323 |
* Added Python version trove classifiers: 2.4, 2.5, 2.6 and 2.7 |
| 324 |
|
| 325 |
* Tests now passing on Python 2.7. |
| 326 |
|
| 327 |
* Task.__reduce__: Tasks created using the task decorator can now be pickled. |
| 328 |
|
| 329 |
* :file:`setup.py`: :pypi:`nose` added to `tests_require`. |
| 330 |
|
| 331 |
* Pickle should now work with SQLAlchemy 0.5.x |
| 332 |
|
| 333 |
* New homepage design by Jan Henrik Helmers: http://celeryproject.org |
| 334 |
|
| 335 |
* New Sphinx theme by Armin Ronacher: https://docs.celeryq.dev/ |
| 336 |
|
| 337 |
* Fixed "pending_xref" errors shown in the HTML rendering of the |
| 338 |
documentation. Apparently this was caused by new changes in Sphinx 1.0b2. |
| 339 |
|
| 340 |
* Router classes in :setting:`CELERY_ROUTES` are now imported lazily. |
| 341 |
|
| 342 |
Importing a router class in a module that also loads the Celery |
| 343 |
environment would cause a circular dependency. This is solved |
| 344 |
by importing it when needed after the environment is set up. |
| 345 |
|
| 346 |
* :setting:`CELERY_ROUTES` was broken if set to a single dict. |
| 347 |
|
| 348 |
This example in the docs should now work again: |
| 349 |
|
| 350 |
.. code-block:: python |
| 351 |
|
| 352 |
CELERY_ROUTES = {'feed.tasks.import_feed': 'feeds'} |
| 353 |
|
| 354 |
* `CREATE_MISSING_QUEUES` wasn't honored by apply_async. |
| 355 |
|
| 356 |
* New remote control command: `stats` |
| 357 |
|
| 358 |
Dumps information about the worker, like pool process ids, and |
| 359 |
total number of tasks executed by type. |
| 360 |
|
| 361 |
Example reply: |
| 362 |
|
| 363 |
.. code-block:: python |
| 364 |
|
| 365 |
[{'worker.local': |
| 366 |
'total': {'tasks.sleeptask': 6}, |
| 367 |
'pool': {'timeouts': [None, None], |
| 368 |
'processes': [60376, 60377], |
| 369 |
'max-concurrency': 2, |
| 370 |
'max-tasks-per-child': None, |
| 371 |
'put-guarded-by-semaphore': True}}] |
| 372 |
|
| 373 |
* New remote control command: `dump_active` |
| 374 |
|
| 375 |
Gives a list of tasks currently being executed by the worker. |
| 376 |
By default arguments are passed through repr in case there |
| 377 |
are arguments that's not JSON encodable. If you know |
| 378 |
the arguments are JSON safe, you can pass the argument `safe=True`. |
| 379 |
|
| 380 |
Example reply: |
| 381 |
|
| 382 |
.. code-block:: pycon |
| 383 |
|
| 384 |
>>> broadcast('dump_active', arguments={'safe': False}, reply=True) |
| 385 |
[{'worker.local': [ |
| 386 |
{'args': '(1,)', |
| 387 |
'time_start': 1278580542.6300001, |
| 388 |
'name': 'tasks.sleeptask', |
| 389 |
'delivery_info': { |
| 390 |
'consumer_tag': '30', |
| 391 |
'routing_key': 'celery', |
| 392 |
'exchange': 'celery'}, |
| 393 |
'hostname': 'casper.local', |
| 394 |
'acknowledged': True, |
| 395 |
'kwargs': '{}', |
| 396 |
'id': '802e93e9-e470-47ed-b913-06de8510aca2', |
| 397 |
} |
| 398 |
]}] |
| 399 |
|
| 400 |
* Added experimental support for persistent revokes. |
| 401 |
|
| 402 |
Use the `-S|--statedb` argument to the worker to enable it: |
| 403 |
|
| 404 |
.. code-block:: console |
| 405 |
|
| 406 |
$ celeryd --statedb=/var/run/celeryd |
| 407 |
|
| 408 |
This will use the file: `/var/run/celeryd.db`, |
| 409 |
as the `shelve` module automatically adds the `.db` suffix. |
| 410 |
|
| 411 |
.. _version-2.0.0: |
| 412 |
|
| 413 |
2.0.0 |
| 414 |
===== |
| 415 |
:release-date: 2010-07-02 02:30 p.m. CEST |
| 416 |
:release-by: Ask Solem |
| 417 |
|
| 418 |
Foreword |
| 419 |
-------- |
| 420 |
|
| 421 |
Celery 2.0 contains backward incompatible changes, the most important |
| 422 |
being that the Django dependency has been removed so Celery no longer |
| 423 |
supports Django out of the box, but instead as an add-on package |
| 424 |
called :pypi:`django-celery`. |
| 425 |
|
| 426 |
We're very sorry for breaking backwards compatibility, but there's |
| 427 |
also many new and exciting features to make up for the time you lose |
| 428 |
upgrading, so be sure to read the :ref:`News <v200-news>` section. |
| 429 |
|
| 430 |
Quite a lot of potential users have been upset about the Django dependency, |
| 431 |
so maybe this is a chance to get wider adoption by the Python community as |
| 432 |
well. |
| 433 |
|
| 434 |
Big thanks to all contributors, testers and users! |
| 435 |
|
| 436 |
.. _v200-django-upgrade: |
| 437 |
|
| 438 |
Upgrading for Django-users |
| 439 |
-------------------------- |
| 440 |
|
| 441 |
Django integration has been moved to a separate package: :pypi:`django-celery`. |
| 442 |
|
| 443 |
* To upgrade you need to install the :pypi:`django-celery` module and change: |
| 444 |
|
| 445 |
.. code-block:: python |
| 446 |
|
| 447 |
INSTALLED_APPS = 'celery' |
| 448 |
|
| 449 |
to: |
| 450 |
|
| 451 |
.. code-block:: python |
| 452 |
|
| 453 |
INSTALLED_APPS = 'djcelery' |
| 454 |
|
| 455 |
* If you use `mod_wsgi` you need to add the following line to your `.wsgi` |
| 456 |
file: |
| 457 |
|
| 458 |
.. code-block:: python |
| 459 |
|
| 460 |
import os |
| 461 |
os.environ['CELERY_LOADER'] = 'django' |
| 462 |
|
| 463 |
* The following modules has been moved to :pypi:`django-celery`: |
| 464 |
|
| 465 |
===================================== ===================================== |
| 466 |
**Module name** **Replace with** |
| 467 |
===================================== ===================================== |
| 468 |
`celery.models` `djcelery.models` |
| 469 |
`celery.managers` `djcelery.managers` |
| 470 |
`celery.views` `djcelery.views` |
| 471 |
`celery.urls` `djcelery.urls` |
| 472 |
`celery.management` `djcelery.management` |
| 473 |
`celery.loaders.djangoapp` `djcelery.loaders` |
| 474 |
`celery.backends.database` `djcelery.backends.database` |
| 475 |
`celery.backends.cache` `djcelery.backends.cache` |
| 476 |
===================================== ===================================== |
| 477 |
|
| 478 |
Importing :mod:`djcelery` will automatically setup Celery to use Django loader. |
| 479 |
loader. It does this by setting the :envvar:`CELERY_LOADER` environment variable to |
| 480 |
`"django"` (it won't change it if a loader is already set). |
| 481 |
|
| 482 |
When the Django loader is used, the "database" and "cache" result backend |
| 483 |
aliases will point to the :mod:`djcelery` backends instead of the built-in backends, |
| 484 |
and configuration will be read from the Django settings. |
| 485 |
|
| 486 |
.. _v200-upgrade: |
| 487 |
|
| 488 |
Upgrading for others |
| 489 |
-------------------- |
| 490 |
|
| 491 |
.. _v200-upgrade-database: |
| 492 |
|
| 493 |
Database result backend |
| 494 |
~~~~~~~~~~~~~~~~~~~~~~~ |
| 495 |
|
| 496 |
The database result backend is now using `SQLAlchemy`_ instead of the |
| 497 |
Django ORM, see `Supported Databases`_ for a table of supported databases. |
| 498 |
|
| 499 |
The `DATABASE_*` settings has been replaced by a single setting: |
| 500 |
:setting:`CELERY_RESULT_DBURI`. The value here should be an |
| 501 |
`SQLAlchemy Connection String`_, some examples include: |
| 502 |
|
| 503 |
.. code-block:: python |
| 504 |
|
| 505 |
# sqlite (filename) |
| 506 |
CELERY_RESULT_DBURI = 'sqlite:///celerydb.sqlite' |
| 507 |
|
| 508 |
# mysql |
| 509 |
CELERY_RESULT_DBURI = 'mysql://scott:tiger@localhost/foo' |
| 510 |
|
| 511 |
# postgresql |
| 512 |
CELERY_RESULT_DBURI = 'postgresql://scott:tiger@localhost/mydatabase' |
| 513 |
|
| 514 |
# oracle |
| 515 |
CELERY_RESULT_DBURI = 'oracle://scott:[email protected]:1521/sidname' |
| 516 |
|
| 517 |
See `SQLAlchemy Connection Strings`_ for more information about connection |
| 518 |
strings. |
| 519 |
|
| 520 |
To specify additional SQLAlchemy database engine options you can use |
| 521 |
the :setting:`CELERY_RESULT_ENGINE_OPTIONS` setting: |
| 522 |
|
| 523 |
.. code-block:: python |
| 524 |
|
| 525 |
# echo enables verbose logging from SQLAlchemy. |
| 526 |
CELERY_RESULT_ENGINE_OPTIONS = {'echo': True} |
| 527 |
|
| 528 |
.. _`SQLAlchemy`: |
| 529 |
http://www.sqlalchemy.org |
| 530 |
.. _`Supported Databases`: |
| 531 |
http://www.sqlalchemy.org/docs/core/engines.html#supported-databases |
| 532 |
.. _`SQLAlchemy Connection String`: |
| 533 |
http://www.sqlalchemy.org/docs/core/engines.html#database-urls |
| 534 |
.. _`SQLAlchemy Connection Strings`: |
| 535 |
http://www.sqlalchemy.org/docs/core/engines.html#database-urls |
| 536 |
|
| 537 |
.. _v200-upgrade-cache: |
| 538 |
|
| 539 |
Cache result backend |
| 540 |
~~~~~~~~~~~~~~~~~~~~ |
| 541 |
|
| 542 |
The cache result backend is no longer using the Django cache framework, |
| 543 |
but it supports mostly the same configuration syntax: |
| 544 |
|
| 545 |
.. code-block:: python |
| 546 |
|
| 547 |
CELERY_CACHE_BACKEND = 'memcached://A.example.com:11211;B.example.com' |
| 548 |
|
| 549 |
To use the cache backend you must either have the :pypi:`pylibmc` or |
| 550 |
:pypi:`python-memcached` library installed, of which the former is regarded |
| 551 |
as the best choice. |
| 552 |
|
| 553 |
The support backend types are `memcached://` and `memory://`, |
| 554 |
we haven't felt the need to support any of the other backends |
| 555 |
provided by Django. |
| 556 |
|
| 557 |
.. _v200-incompatible: |
| 558 |
|
| 559 |
Backward incompatible changes |
| 560 |
----------------------------- |
| 561 |
|
| 562 |
* Default (python) loader now prints warning on missing `celeryconfig.py` |
| 563 |
instead of raising :exc:`ImportError`. |
| 564 |
|
| 565 |
The worker raises :exc:`~@ImproperlyConfigured` if the configuration |
| 566 |
isn't set up. This makes it possible to use `--help` etc., without having a |
| 567 |
working configuration. |
| 568 |
|
| 569 |
Also this makes it possible to use the client side of Celery without being |
| 570 |
configured: |
| 571 |
|
| 572 |
.. code-block:: pycon |
| 573 |
|
| 574 |
>>> from carrot.connection import BrokerConnection |
| 575 |
>>> conn = BrokerConnection('localhost', 'guest', 'guest', '/') |
| 576 |
>>> from celery.execute import send_task |
| 577 |
>>> r = send_task('celery.ping', args=(), kwargs={}, connection=conn) |
| 578 |
>>> from celery.backends.amqp import AMQPBackend |
| 579 |
>>> r.backend = AMQPBackend(connection=conn) |
| 580 |
>>> r.get() |
| 581 |
'pong' |
| 582 |
|
| 583 |
* The following deprecated settings has been removed (as scheduled by |
| 584 |
the :ref:`deprecation-timeline`): |
| 585 |
|
| 586 |
===================================== ===================================== |
| 587 |
**Setting name** **Replace with** |
| 588 |
===================================== ===================================== |
| 589 |
`CELERY_AMQP_CONSUMER_QUEUES` `CELERY_QUEUES` |
| 590 |
`CELERY_AMQP_EXCHANGE` `CELERY_DEFAULT_EXCHANGE` |
| 591 |
`CELERY_AMQP_EXCHANGE_TYPE` `CELERY_DEFAULT_EXCHANGE_TYPE` |
| 592 |
`CELERY_AMQP_CONSUMER_ROUTING_KEY` `CELERY_QUEUES` |
| 593 |
`CELERY_AMQP_PUBLISHER_ROUTING_KEY` `CELERY_DEFAULT_ROUTING_KEY` |
| 594 |
===================================== ===================================== |
| 595 |
|
| 596 |
* The `celery.task.rest` module has been removed, use `celery.task.http` |
| 597 |
instead (as scheduled by the :ref:`deprecation-timeline`). |
| 598 |
|
| 599 |
* It's no longer allowed to skip the class name in loader names. |
| 600 |
(as scheduled by the :ref:`deprecation-timeline`): |
| 601 |
|
| 602 |
Assuming the implicit `Loader` class name is no longer supported, |
| 603 |
for example, if you use: |
| 604 |
|
| 605 |
.. code-block:: python |
| 606 |
|
| 607 |
CELERY_LOADER = 'myapp.loaders' |
| 608 |
|
| 609 |
You need to include the loader class name, like this: |
| 610 |
|
| 611 |
.. code-block:: python |
| 612 |
|
| 613 |
CELERY_LOADER = 'myapp.loaders.Loader' |
| 614 |
|
| 615 |
* :setting:`CELERY_TASK_RESULT_EXPIRES` now defaults to 1 day. |
| 616 |
|
| 617 |
Previous default setting was to expire in 5 days. |
| 618 |
|
| 619 |
* AMQP backend: Don't use different values for `auto_delete`. |
| 620 |
|
| 621 |
This bug became visible with RabbitMQ 1.8.0, which no longer |
| 622 |
allows conflicting declarations for the auto_delete and durable settings. |
| 623 |
|
| 624 |
If you've already used Celery with this backend chances are you |
| 625 |
have to delete the previous declaration: |
| 626 |
|
| 627 |
.. code-block:: console |
| 628 |
|
| 629 |
$ camqadm exchange.delete celeryresults |
| 630 |
|
| 631 |
* Now uses pickle instead of cPickle on Python versions <= 2.5 |
| 632 |
|
| 633 |
cPickle is broken in Python <= 2.5. |
| 634 |
|
| 635 |
It unsafely and incorrectly uses relative instead of absolute imports, |
| 636 |
so for example: |
| 637 |
|
| 638 |
.. code-block:: python |
| 639 |
|
| 640 |
exceptions.KeyError |
| 641 |
|
| 642 |
becomes: |
| 643 |
|
| 644 |
.. code-block:: python |
| 645 |
|
| 646 |
celery.exceptions.KeyError |
| 647 |
|
| 648 |
Your best choice is to upgrade to Python 2.6, |
| 649 |
as while the pure pickle version has worse performance, |
| 650 |
it is the only safe option for older Python versions. |
| 651 |
|
| 652 |
.. _v200-news: |
| 653 |
|
| 654 |
News |
| 655 |
---- |
| 656 |
|
| 657 |
* **celeryev**: Curses Celery Monitor and Event Viewer. |
| 658 |
|
| 659 |
This is a simple monitor allowing you to see what tasks are |
| 660 |
executing in real-time and investigate tracebacks and results of ready |
| 661 |
tasks. It also enables you to set new rate limits and revoke tasks. |
| 662 |
|
| 663 |
Screenshot: |
| 664 |
|
| 665 |
.. figure:: ../images/celeryevshotsm.jpg |
| 666 |
|
| 667 |
If you run `celeryev` with the `-d` switch it will act as an event |
| 668 |
dumper, simply dumping the events it receives to standard out: |
| 669 |
|
| 670 |
.. code-block:: console |
| 671 |
|
| 672 |
$ celeryev -d |
| 673 |
-> celeryev: starting capture... |
| 674 |
casper.local [2010-06-04 10:42:07.020000] heartbeat |
| 675 |
casper.local [2010-06-04 10:42:14.750000] task received: |
| 676 |
tasks.add(61a68756-27f4-4879-b816-3cf815672b0e) args=[2, 2] kwargs={} |
| 677 |
eta=2010-06-04T10:42:16.669290, retries=0 |
| 678 |
casper.local [2010-06-04 10:42:17.230000] task started |
| 679 |
tasks.add(61a68756-27f4-4879-b816-3cf815672b0e) args=[2, 2] kwargs={} |
| 680 |
casper.local [2010-06-04 10:42:17.960000] task succeeded: |
| 681 |
tasks.add(61a68756-27f4-4879-b816-3cf815672b0e) |
| 682 |
args=[2, 2] kwargs={} result=4, runtime=0.782663106918 |
| 683 |
|
| 684 |
The fields here are, in order: *sender hostname*, *timestamp*, *event type* and |
| 685 |
*additional event fields*. |
| 686 |
|
| 687 |
* AMQP result backend: Now supports `.ready()`, `.successful()`, |
| 688 |
`.result`, `.status`, and even responds to changes in task state |
| 689 |
|
| 690 |
* New user guides: |
| 691 |
|
| 692 |
* :ref:`guide-workers` |
| 693 |
* :ref:`guide-canvas` |
| 694 |
* :ref:`guide-routing` |
| 695 |
|
| 696 |
* Worker: Standard out/error is now being redirected to the log file. |
| 697 |
|
| 698 |
* :pypi:`billiard` has been moved back to the Celery repository. |
| 699 |
|
| 700 |
===================================== ===================================== |
| 701 |
**Module name** **celery equivalent** |
| 702 |
===================================== ===================================== |
| 703 |
`billiard.pool` `celery.concurrency.processes.pool` |
| 704 |
`billiard.serialization` `celery.serialization` |
| 705 |
`billiard.utils.functional` `celery.utils.functional` |
| 706 |
===================================== ===================================== |
| 707 |
|
| 708 |
The :pypi:`billiard` distribution may be maintained, depending on interest. |
| 709 |
|
| 710 |
* now depends on :pypi:`carrot` >= 0.10.5 |
| 711 |
|
| 712 |
* now depends on :pypi:`pyparsing` |
| 713 |
|
| 714 |
* Worker: Added `--purge` as an alias to `--discard`. |
| 715 |
|
| 716 |
* Worker: :kbd:`Control-c` (SIGINT) once does warm shutdown, |
| 717 |
hitting :kbd:`Control-c` twice forces termination. |
| 718 |
|
| 719 |
* Added support for using complex Crontab-expressions in periodic tasks. For |
| 720 |
example, you can now use: |
| 721 |
|
| 722 |
.. code-block:: pycon |
| 723 |
|
| 724 |
>>> crontab(minute='*/15') |
| 725 |
|
| 726 |
or even: |
| 727 |
|
| 728 |
.. code-block:: pycon |
| 729 |
|
| 730 |
>>> crontab(minute='*/30', hour='8-17,1-2', day_of_week='thu-fri') |
| 731 |
|
| 732 |
See :ref:`guide-beat`. |
| 733 |
|
| 734 |
* Worker: Now waits for available pool processes before applying new |
| 735 |
tasks to the pool. |
| 736 |
|
| 737 |
This means it doesn't have to wait for dozens of tasks to finish at shutdown |
| 738 |
because it has applied prefetched tasks without having any pool |
| 739 |
processes available to immediately accept them. |
| 740 |
|
| 741 |
See issue #122. |
| 742 |
|
| 743 |
* New built-in way to do task callbacks using |
| 744 |
:class:`~celery.subtask`. |
| 745 |
|
| 746 |
See :ref:`guide-canvas` for more information. |
| 747 |
|
| 748 |
* TaskSets can now contain several types of tasks. |
| 749 |
|
| 750 |
:class:`~celery.task.sets.TaskSet` has been refactored to use |
| 751 |
a new syntax, please see :ref:`guide-canvas` for more information. |
| 752 |
|
| 753 |
The previous syntax is still supported, but will be deprecated in |
| 754 |
version 1.4. |
| 755 |
|
| 756 |
* TaskSet failed() result was incorrect. |
| 757 |
|
| 758 |
See issue #132. |
| 759 |
|
| 760 |
* Now creates different loggers per task class. |
| 761 |
|
| 762 |
See issue #129. |
| 763 |
|
| 764 |
* Missing queue definitions are now created automatically. |
| 765 |
|
| 766 |
You can disable this using the :setting:`CELERY_CREATE_MISSING_QUEUES` |
| 767 |
setting. |
| 768 |
|
| 769 |
The missing queues are created with the following options: |
| 770 |
|
| 771 |
.. code-block:: python |
| 772 |
|
| 773 |
CELERY_QUEUES[name] = {'exchange': name, |
| 774 |
'exchange_type': 'direct', |
| 775 |
'routing_key': 'name} |
| 776 |
|
| 777 |
This feature is added for easily setting up routing using the `-Q` |
| 778 |
option to the worker: |
| 779 |
|
| 780 |
.. code-block:: console |
| 781 |
|
| 782 |
$ celeryd -Q video, image |
| 783 |
|
| 784 |
See the new routing section of the User Guide for more information: |
| 785 |
:ref:`guide-routing`. |
| 786 |
|
| 787 |
* New Task option: `Task.queue` |
| 788 |
|
| 789 |
If set, message options will be taken from the corresponding entry |
| 790 |
in :setting:`CELERY_QUEUES`. `exchange`, `exchange_type` and `routing_key` |
| 791 |
will be ignored |
| 792 |
|
| 793 |
* Added support for task soft and hard time limits. |
| 794 |
|
| 795 |
New settings added: |
| 796 |
|
| 797 |
* :setting:`CELERYD_TASK_TIME_LIMIT` |
| 798 |
|
| 799 |
Hard time limit. The worker processing the task will be killed and |
| 800 |
replaced with a new one when this is exceeded. |
| 801 |
|
| 802 |
* :setting:`CELERYD_TASK_SOFT_TIME_LIMIT` |
| 803 |
|
| 804 |
Soft time limit. The :exc:`~@SoftTimeLimitExceeded` |
| 805 |
exception will be raised when this is exceeded. The task can catch |
| 806 |
this to, for example, clean up before the hard time limit comes. |
| 807 |
|
| 808 |
New command-line arguments to ``celeryd`` added: |
| 809 |
`--time-limit` and `--soft-time-limit`. |
| 810 |
|
| 811 |
What's left? |
| 812 |
|
| 813 |
This won't work on platforms not supporting signals (and specifically |
| 814 |
the `SIGUSR1` signal) yet. So an alternative the ability to disable |
| 815 |
the feature all together on nonconforming platforms must be implemented. |
| 816 |
|
| 817 |
Also when the hard time limit is exceeded, the task result should |
| 818 |
be a `TimeLimitExceeded` exception. |
| 819 |
|
| 820 |
* Test suite is now passing without a running broker, using the carrot |
| 821 |
in-memory backend. |
| 822 |
|
| 823 |
* Log output is now available in colors. |
| 824 |
|
| 825 |
===================================== ===================================== |
| 826 |
**Log level** **Color** |
| 827 |
===================================== ===================================== |
| 828 |
`DEBUG` Blue |
| 829 |
`WARNING` Yellow |
| 830 |
`CRITICAL` Magenta |
| 831 |
`ERROR` Red |
| 832 |
===================================== ===================================== |
| 833 |
|
| 834 |
This is only enabled when the log output is a tty. |
| 835 |
You can explicitly enable/disable this feature using the |
| 836 |
:setting:`CELERYD_LOG_COLOR` setting. |
| 837 |
|
| 838 |
* Added support for task router classes (like the django multi-db routers) |
| 839 |
|
| 840 |
* New setting: :setting:`CELERY_ROUTES` |
| 841 |
|
| 842 |
This is a single, or a list of routers to traverse when |
| 843 |
sending tasks. Dictionaries in this list converts to a |
| 844 |
:class:`celery.routes.MapRoute` instance. |
| 845 |
|
| 846 |
Examples: |
| 847 |
|
| 848 |
>>> CELERY_ROUTES = {'celery.ping': 'default', |
| 849 |
'mytasks.add': 'cpu-bound', |
| 850 |
'video.encode': { |
| 851 |
'queue': 'video', |
| 852 |
'exchange': 'media' |
| 853 |
'routing_key': 'media.video.encode'}} |
| 854 |
|
| 855 |
>>> CELERY_ROUTES = ('myapp.tasks.Router', |
| 856 |
{'celery.ping': 'default'}) |
| 857 |
|
| 858 |
Where `myapp.tasks.Router` could be: |
| 859 |
|
| 860 |
.. code-block:: python |
| 861 |
|
| 862 |
class Router(object): |
| 863 |
|
| 864 |
def route_for_task(self, task, args=None, kwargs=None): |
| 865 |
if task == 'celery.ping': |
| 866 |
return 'default' |
| 867 |
|
| 868 |
route_for_task may return a string or a dict. A string then means |
| 869 |
it's a queue name in :setting:`CELERY_QUEUES`, a dict means it's a custom route. |
| 870 |
|
| 871 |
When sending tasks, the routers are consulted in order. The first |
| 872 |
router that doesn't return `None` is the route to use. The message options |
| 873 |
is then merged with the found route settings, where the routers settings |
| 874 |
have priority. |
| 875 |
|
| 876 |
Example if :func:`~celery.execute.apply_async` has these arguments: |
| 877 |
|
| 878 |
.. code-block:: pycon |
| 879 |
|
| 880 |
>>> Task.apply_async(immediate=False, exchange='video', |
| 881 |
... routing_key='video.compress') |
| 882 |
|
| 883 |
and a router returns: |
| 884 |
|
| 885 |
.. code-block:: python |
| 886 |
|
| 887 |
{'immediate': True, |
| 888 |
'exchange': 'urgent'} |
| 889 |
|
| 890 |
the final message options will be: |
| 891 |
|
| 892 |
.. code-block:: pycon |
| 893 |
|
| 894 |
>>> task.apply_async( |
| 895 |
... immediate=True, |
| 896 |
... exchange='urgent', |
| 897 |
... routing_key='video.compress', |
| 898 |
... ) |
| 899 |
|
| 900 |
(and any default message options defined in the |
| 901 |
:class:`~celery.task.base.Task` class) |
| 902 |
|
| 903 |
* New Task handler called after the task returns: |
| 904 |
:meth:`~celery.task.base.Task.after_return`. |
| 905 |
|
| 906 |
* :class:`~billiard.einfo.ExceptionInfo` now passed to |
| 907 |
:meth:`~celery.task.base.Task.on_retry`/ |
| 908 |
:meth:`~celery.task.base.Task.on_failure` as ``einfo`` keyword argument. |
| 909 |
|
| 910 |
* Worker: Added :setting:`CELERYD_MAX_TASKS_PER_CHILD` / |
| 911 |
``celery worker --maxtasksperchild``. |
| 912 |
|
| 913 |
Defines the maximum number of tasks a pool worker can process before |
| 914 |
the process is terminated and replaced by a new one. |
| 915 |
|
| 916 |
* Revoked tasks now marked with state :state:`REVOKED`, and `result.get()` |
| 917 |
will now raise :exc:`~@TaskRevokedError`. |
| 918 |
|
| 919 |
* :func:`celery.task.control.ping` now works as expected. |
| 920 |
|
| 921 |
* `apply(throw=True)` / :setting:`CELERY_EAGER_PROPAGATES_EXCEPTIONS`: |
| 922 |
Makes eager execution re-raise task errors. |
| 923 |
|
| 924 |
* New signal: :signal:`~celery.signals.worker_process_init`: Sent inside the |
| 925 |
pool worker process at init. |
| 926 |
|
| 927 |
* Worker: :option:`celery worker -Q` option: Ability to specify list of queues |
| 928 |
to use, disabling other configured queues. |
| 929 |
|
| 930 |
For example, if :setting:`CELERY_QUEUES` defines four |
| 931 |
queues: `image`, `video`, `data` and `default`, the following |
| 932 |
command would make the worker only consume from the `image` and `video` |
| 933 |
queues: |
| 934 |
|
| 935 |
.. code-block:: console |
| 936 |
|
| 937 |
$ celeryd -Q image,video |
| 938 |
|
| 939 |
* Worker: New return value for the `revoke` control command: |
| 940 |
|
| 941 |
Now returns: |
| 942 |
|
| 943 |
.. code-block:: python |
| 944 |
|
| 945 |
{'ok': 'task $id revoked'} |
| 946 |
|
| 947 |
instead of :const:`True`. |
| 948 |
|
| 949 |
* Worker: Can now enable/disable events using remote control |
| 950 |
|
| 951 |
Example usage: |
| 952 |
|
| 953 |
>>> from celery.task.control import broadcast |
| 954 |
>>> broadcast('enable_events') |
| 955 |
>>> broadcast('disable_events') |
| 956 |
|
| 957 |
* Removed top-level tests directory. Test config now in celery.tests.config |
| 958 |
|
| 959 |
This means running the unit tests doesn't require any special setup. |
| 960 |
`celery/tests/__init__` now configures the :envvar:`CELERY_CONFIG_MODULE` |
| 961 |
and :envvar:`CELERY_LOADER` environment variables, so when `nosetests` |
| 962 |
imports that, the unit test environment is all set up. |
| 963 |
|
| 964 |
Before you run the tests you need to install the test requirements: |
| 965 |
|
| 966 |
.. code-block:: console |
| 967 |
|
| 968 |
$ pip install -r requirements/test.txt |
| 969 |
|
| 970 |
Running all tests: |
| 971 |
|
| 972 |
.. code-block:: console |
| 973 |
|
| 974 |
$ nosetests |
| 975 |
|
| 976 |
Specifying the tests to run: |
| 977 |
|
| 978 |
.. code-block:: console |
| 979 |
|
| 980 |
$ nosetests celery.tests.test_task |
| 981 |
|
| 982 |
Producing HTML coverage: |
| 983 |
|
| 984 |
.. code-block:: console |
| 985 |
|
| 986 |
$ nosetests --with-coverage3 |
| 987 |
|
| 988 |
The coverage output is then located in `celery/tests/cover/index.html`. |
| 989 |
|
| 990 |
* Worker: New option `--version`: Dump version info and exit. |
| 991 |
|
| 992 |
* :mod:`celeryd-multi <celeryd.bin.multi>`: Tool for shell scripts |
| 993 |
to start multiple workers. |
| 994 |
|
| 995 |
Some examples: |
| 996 |
|
| 997 |
- Advanced example with 10 workers: |
| 998 |
|
| 999 |
* Three of the workers processes the images and video queue |
| 1000 |
* Two of the workers processes the data queue with loglevel DEBUG |
| 1001 |
* the rest processes the default' queue. |
| 1002 |
|
| 1003 |
.. code-block:: console |
| 1004 |
|
| 1005 |
$ celeryd-multi start 10 -l INFO -Q:1-3 images,video -Q:4,5:data -Q default -L:4,5 DEBUG |
| 1006 |
|
| 1007 |
- Get commands to start 10 workers, with 3 processes each |
| 1008 |
|
| 1009 |
.. code-block:: console |
| 1010 |
|
| 1011 |
$ celeryd-multi start 3 -c 3 |
| 1012 |
celeryd -n celeryd1.myhost -c 3 |
| 1013 |
celeryd -n celeryd2.myhost -c 3 |
| 1014 |
celeryd -n celeryd3.myhost -c 3 |
| 1015 |
|
| 1016 |
- Start 3 named workers |
| 1017 |
|
| 1018 |
.. code-block:: console |
| 1019 |
|
| 1020 |
$ celeryd-multi start image video data -c 3 |
| 1021 |
celeryd -n image.myhost -c 3 |
| 1022 |
celeryd -n video.myhost -c 3 |
| 1023 |
celeryd -n data.myhost -c 3 |
| 1024 |
|
| 1025 |
- Specify custom hostname |
| 1026 |
|
| 1027 |
.. code-block:: console |
| 1028 |
|
| 1029 |
$ celeryd-multi start 2 -n worker.example.com -c 3 |
| 1030 |
celeryd -n celeryd1.worker.example.com -c 3 |
| 1031 |
celeryd -n celeryd2.worker.example.com -c 3 |
| 1032 |
|
| 1033 |
Additional options are added to each ``celeryd``, |
| 1034 |
but you can also modify the options for ranges of or single workers |
| 1035 |
|
| 1036 |
- 3 workers: Two with 3 processes, and one with 10 processes. |
| 1037 |
|
| 1038 |
.. code-block:: console |
| 1039 |
|
| 1040 |
$ celeryd-multi start 3 -c 3 -c:1 10 |
| 1041 |
celeryd -n celeryd1.myhost -c 10 |
| 1042 |
celeryd -n celeryd2.myhost -c 3 |
| 1043 |
celeryd -n celeryd3.myhost -c 3 |
| 1044 |
|
| 1045 |
- Can also specify options for named workers |
| 1046 |
|
| 1047 |
.. code-block:: console |
| 1048 |
|
| 1049 |
$ celeryd-multi start image video data -c 3 -c:image 10 |
| 1050 |
celeryd -n image.myhost -c 10 |
| 1051 |
celeryd -n video.myhost -c 3 |
| 1052 |
celeryd -n data.myhost -c 3 |
| 1053 |
|
| 1054 |
- Ranges and lists of workers in options is also allowed: |
| 1055 |
(``-c:1-3`` can also be written as ``-c:1,2,3``) |
| 1056 |
|
| 1057 |
.. code-block:: console |
| 1058 |
|
| 1059 |
$ celeryd-multi start 5 -c 3 -c:1-3 10 |
| 1060 |
celeryd-multi -n celeryd1.myhost -c 10 |
| 1061 |
celeryd-multi -n celeryd2.myhost -c 10 |
| 1062 |
celeryd-multi -n celeryd3.myhost -c 10 |
| 1063 |
celeryd-multi -n celeryd4.myhost -c 3 |
| 1064 |
celeryd-multi -n celeryd5.myhost -c 3 |
| 1065 |
|
| 1066 |
- Lists also work with named workers: |
| 1067 |
|
| 1068 |
.. code-block:: console |
| 1069 |
|
| 1070 |
$ celeryd-multi start foo bar baz xuzzy -c 3 -c:foo,bar,baz 10 |
| 1071 |
celeryd-multi -n foo.myhost -c 10 |
| 1072 |
celeryd-multi -n bar.myhost -c 10 |
| 1073 |
celeryd-multi -n baz.myhost -c 10 |
| 1074 |
celeryd-multi -n xuzzy.myhost -c 3 |
| 1075 |
|
| 1076 |
* The worker now calls the result backends `process_cleanup` method |
| 1077 |
*after* task execution instead of before. |
| 1078 |
|
| 1079 |
* AMQP result backend now supports Pika. |