| 1 |
.. _changelog-2.2: |
| 2 |
|
| 3 |
=============================== |
| 4 |
Change history for Celery 2.2 |
| 5 |
=============================== |
| 6 |
|
| 7 |
.. contents:: |
| 8 |
:local: |
| 9 |
|
| 10 |
.. _version-2.2.8: |
| 11 |
|
| 12 |
2.2.8 |
| 13 |
===== |
| 14 |
:release-date: 2011-11-25 04:00 p.m. GMT |
| 15 |
:release-by: Ask Solem |
| 16 |
|
| 17 |
.. _v228-security-fixes: |
| 18 |
|
| 19 |
Security Fixes |
| 20 |
-------------- |
| 21 |
|
| 22 |
* [Security: `CELERYSA-0001`_] Daemons would set effective id's rather than |
| 23 |
real id's when the :option:`!--uid`/ |
| 24 |
:option:`!--gid` arguments to :program:`celery multi`, |
| 25 |
:program:`celeryd_detach`, :program:`celery beat` and |
| 26 |
:program:`celery events` were used. |
| 27 |
|
| 28 |
This means privileges weren't properly dropped, and that it would |
| 29 |
be possible to regain supervisor privileges later. |
| 30 |
|
| 31 |
|
| 32 |
.. _`CELERYSA-0001`: |
| 33 |
https://github.com/celery/celery/tree/master/docs/sec/CELERYSA-0001.txt |
| 34 |
|
| 35 |
.. _version-2.2.7: |
| 36 |
|
| 37 |
2.2.7 |
| 38 |
===== |
| 39 |
:release-date: 2011-06-13 04:00 p.m. BST |
| 40 |
:release-by: Ask Solem |
| 41 |
|
| 42 |
* New signals: :signal:`after_setup_logger` and |
| 43 |
:signal:`after_setup_task_logger` |
| 44 |
|
| 45 |
These signals can be used to augment logging configuration |
| 46 |
after Celery has set up logging. |
| 47 |
|
| 48 |
* Redis result backend now works with Redis 2.4.4. |
| 49 |
|
| 50 |
* multi: The :option:`!--gid` option now works correctly. |
| 51 |
|
| 52 |
* worker: Retry wrongfully used the repr of the traceback instead |
| 53 |
of the string representation. |
| 54 |
|
| 55 |
* App.config_from_object: Now loads module, not attribute of module. |
| 56 |
|
| 57 |
* Fixed issue where logging of objects would give "<Unrepresentable: ...>" |
| 58 |
|
| 59 |
.. _version-2.2.6: |
| 60 |
|
| 61 |
2.2.6 |
| 62 |
===== |
| 63 |
:release-date: 2011-04-15 04:00 p.m. CEST |
| 64 |
:release-by: Ask Solem |
| 65 |
|
| 66 |
.. _v226-important: |
| 67 |
|
| 68 |
Important Notes |
| 69 |
--------------- |
| 70 |
|
| 71 |
* Now depends on :pypi:`Kombu` 1.1.2. |
| 72 |
|
| 73 |
* Dependency lists now explicitly specifies that we don't want |
| 74 |
:pypi:`python-dateutil` 2.x, as this version only supports Python 3. |
| 75 |
|
| 76 |
If you have installed dateutil 2.0 by accident you should downgrade |
| 77 |
to the 1.5.0 version: |
| 78 |
|
| 79 |
.. code-block:: console |
| 80 |
|
| 81 |
$ pip install -U python-dateutil==1.5.0 |
| 82 |
|
| 83 |
or by ``easy_install``: |
| 84 |
|
| 85 |
.. code-block:: console |
| 86 |
|
| 87 |
$ easy_install -U python-dateutil==1.5.0 |
| 88 |
|
| 89 |
.. _v226-fixes: |
| 90 |
|
| 91 |
Fixes |
| 92 |
----- |
| 93 |
|
| 94 |
* The new ``WatchedFileHandler`` broke Python 2.5 support (Issue #367). |
| 95 |
|
| 96 |
* Task: Don't use ``app.main`` if the task name is set explicitly. |
| 97 |
|
| 98 |
* Sending emails didn't work on Python 2.5, due to a bug in |
| 99 |
the version detection code (Issue #378). |
| 100 |
|
| 101 |
* Beat: Adds method ``ScheduleEntry._default_now`` |
| 102 |
|
| 103 |
This method can be overridden to change the default value |
| 104 |
of ``last_run_at``. |
| 105 |
|
| 106 |
* An error occurring in process cleanup could mask task errors. |
| 107 |
|
| 108 |
We no longer propagate errors happening at process cleanup, |
| 109 |
but log them instead. This way they won't interfere with publishing |
| 110 |
the task result (Issue #365). |
| 111 |
|
| 112 |
* Defining tasks didn't work properly when using the Django |
| 113 |
``shell_plus`` utility (Issue #366). |
| 114 |
|
| 115 |
* ``AsyncResult.get`` didn't accept the ``interval`` and ``propagate`` |
| 116 |
arguments. |
| 117 |
|
| 118 |
* worker: Fixed a bug where the worker wouldn't shutdown if a |
| 119 |
:exc:`socket.error` was raised. |
| 120 |
|
| 121 |
.. _version-2.2.5: |
| 122 |
|
| 123 |
2.2.5 |
| 124 |
===== |
| 125 |
:release-date: 2011-03-28 06:00 p.m. CEST |
| 126 |
:release-by: Ask Solem |
| 127 |
|
| 128 |
.. _v225-important: |
| 129 |
|
| 130 |
Important Notes |
| 131 |
--------------- |
| 132 |
|
| 133 |
* Now depends on Kombu 1.0.7 |
| 134 |
|
| 135 |
.. _v225-news: |
| 136 |
|
| 137 |
News |
| 138 |
---- |
| 139 |
|
| 140 |
* Our documentation is now hosted by Read The Docs |
| 141 |
(https://docs.celeryq.dev), and all links have been changed to point to |
| 142 |
the new URL. |
| 143 |
|
| 144 |
* Logging: Now supports log rotation using external tools like `logrotate.d`_ |
| 145 |
(Issue #321) |
| 146 |
|
| 147 |
This is accomplished by using the ``WatchedFileHandler``, which re-opens |
| 148 |
the file if it's renamed or deleted. |
| 149 |
|
| 150 |
.. _`logrotate.d`: |
| 151 |
http://www.ducea.com/2006/06/06/rotating-linux-log-files-part-2-logrotate/ |
| 152 |
|
| 153 |
* ``otherqueues`` tutorial now documents how to configure Redis/Database result |
| 154 |
backends. |
| 155 |
|
| 156 |
* gevent: Now supports ETA tasks. |
| 157 |
|
| 158 |
But gevent still needs ``CELERY_DISABLE_RATE_LIMITS=True`` to work. |
| 159 |
|
| 160 |
* TaskSet User Guide: now contains TaskSet callback recipes. |
| 161 |
|
| 162 |
* Eventlet: New signals: |
| 163 |
|
| 164 |
* ``eventlet_pool_started`` |
| 165 |
* ``eventlet_pool_preshutdown`` |
| 166 |
* ``eventlet_pool_postshutdown`` |
| 167 |
* ``eventlet_pool_apply`` |
| 168 |
|
| 169 |
See :mod:`celery.signals` for more information. |
| 170 |
|
| 171 |
* New :setting:`BROKER_TRANSPORT_OPTIONS` setting can be used to pass |
| 172 |
additional arguments to a particular broker transport. |
| 173 |
|
| 174 |
* worker: ``worker_pid`` is now part of the request info as returned by |
| 175 |
broadcast commands. |
| 176 |
|
| 177 |
* TaskSet.apply/Taskset.apply_async now accepts an optional ``taskset_id`` |
| 178 |
argument. |
| 179 |
|
| 180 |
* The taskset_id (if any) is now available in the Task request context. |
| 181 |
|
| 182 |
* SQLAlchemy result backend: taskset_id and taskset_id columns now have a |
| 183 |
unique constraint (tables need to recreated for this to take affect). |
| 184 |
|
| 185 |
* Task user guide: Added section about choosing a result backend. |
| 186 |
|
| 187 |
* Removed unused attribute ``AsyncResult.uuid``. |
| 188 |
|
| 189 |
.. _v225-fixes: |
| 190 |
|
| 191 |
Fixes |
| 192 |
----- |
| 193 |
|
| 194 |
* multiprocessing.Pool: Fixes race condition when marking job with |
| 195 |
``WorkerLostError`` (Issue #268). |
| 196 |
|
| 197 |
The process may have published a result before it was terminated, |
| 198 |
but we have no reliable way to detect that this is the case. |
| 199 |
|
| 200 |
So we have to wait for 10 seconds before marking the result with |
| 201 |
WorkerLostError. This gives the result handler a chance to retrieve the |
| 202 |
result. |
| 203 |
|
| 204 |
* multiprocessing.Pool: Shutdown could hang if rate limits disabled. |
| 205 |
|
| 206 |
There was a race condition when the MainThread was waiting for the pool |
| 207 |
semaphore to be released. The ResultHandler now terminates after 5 |
| 208 |
seconds if there are unacked jobs, but no worker processes left to start |
| 209 |
them (it needs to timeout because there could still be an ack+result |
| 210 |
that we haven't consumed from the result queue. It |
| 211 |
is unlikely we'll receive any after 5 seconds with no worker processes). |
| 212 |
|
| 213 |
* ``celerybeat``: Now creates pidfile even if the ``--detach`` option isn't set. |
| 214 |
|
| 215 |
* eventlet/gevent: The broadcast command consumer is now running in a separate |
| 216 |
green-thread. |
| 217 |
|
| 218 |
This ensures broadcast commands will take priority even if there are many |
| 219 |
active tasks. |
| 220 |
|
| 221 |
* Internal module ``celery.worker.controllers`` renamed to |
| 222 |
``celery.worker.mediator``. |
| 223 |
|
| 224 |
* worker: Threads now terminates the program by calling ``os._exit``, as it |
| 225 |
is the only way to ensure exit in the case of syntax errors, or other |
| 226 |
unrecoverable errors. |
| 227 |
|
| 228 |
* Fixed typo in ``maybe_timedelta`` (Issue #352). |
| 229 |
|
| 230 |
* worker: Broadcast commands now logs with loglevel debug instead of warning. |
| 231 |
|
| 232 |
* AMQP Result Backend: Now resets cached channel if the connection is lost. |
| 233 |
|
| 234 |
* Polling results with the AMQP result backend wasn't working properly. |
| 235 |
|
| 236 |
* Rate limits: No longer sleeps if there are no tasks, but rather waits for |
| 237 |
the task received condition (Performance improvement). |
| 238 |
|
| 239 |
* ConfigurationView: ``iter(dict)`` should return keys, not items (Issue #362). |
| 240 |
|
| 241 |
* ``celerybeat``: PersistentScheduler now automatically removes a corrupted |
| 242 |
schedule file (Issue #346). |
| 243 |
|
| 244 |
* Programs that doesn't support positional command-line arguments now provides |
| 245 |
a user friendly error message. |
| 246 |
|
| 247 |
* Programs no longer tries to load the configuration file when showing |
| 248 |
``--version`` (Issue #347). |
| 249 |
|
| 250 |
* Autoscaler: The "all processes busy" log message is now severity debug |
| 251 |
instead of error. |
| 252 |
|
| 253 |
* worker: If the message body can't be decoded, it's now passed through |
| 254 |
``safe_str`` when logging. |
| 255 |
|
| 256 |
This to ensure we don't get additional decoding errors when trying to log |
| 257 |
the failure. |
| 258 |
|
| 259 |
* ``app.config_from_object``/``app.config_from_envvar`` now works for all |
| 260 |
loaders. |
| 261 |
|
| 262 |
* Now emits a user-friendly error message if the result backend name is |
| 263 |
unknown (Issue #349). |
| 264 |
|
| 265 |
* ``celery.contrib.batches``: Now sets loglevel and logfile in the task |
| 266 |
request so ``task.get_logger`` works with batch tasks (Issue #357). |
| 267 |
|
| 268 |
* worker: An exception was raised if using the amqp transport and the prefetch |
| 269 |
count value exceeded 65535 (Issue #359). |
| 270 |
|
| 271 |
The prefetch count is incremented for every received task with an |
| 272 |
ETA/countdown defined. The prefetch count is a short, so can only support |
| 273 |
a maximum value of 65535. If the value exceeds the maximum value we now |
| 274 |
disable the prefetch count, it's re-enabled as soon as the value is below |
| 275 |
the limit again. |
| 276 |
|
| 277 |
* ``cursesmon``: Fixed unbound local error (Issue #303). |
| 278 |
|
| 279 |
* eventlet/gevent is now imported on demand so autodoc can import the modules |
| 280 |
without having eventlet/gevent installed. |
| 281 |
|
| 282 |
* worker: Ack callback now properly handles ``AttributeError``. |
| 283 |
|
| 284 |
* ``Task.after_return`` is now always called *after* the result has been |
| 285 |
written. |
| 286 |
|
| 287 |
* Cassandra Result Backend: Should now work with the latest ``pycassa`` |
| 288 |
version. |
| 289 |
|
| 290 |
* multiprocessing.Pool: No longer cares if the ``putlock`` semaphore is released |
| 291 |
too many times (this can happen if one or more worker processes are |
| 292 |
killed). |
| 293 |
|
| 294 |
* SQLAlchemy Result Backend: Now returns accidentally removed ``date_done`` again |
| 295 |
(Issue #325). |
| 296 |
|
| 297 |
* Task.request context is now always initialized to ensure calling the task |
| 298 |
function directly works even if it actively uses the request context. |
| 299 |
|
| 300 |
* Exception occurring when iterating over the result from ``TaskSet.apply`` |
| 301 |
fixed. |
| 302 |
|
| 303 |
* eventlet: Now properly schedules tasks with an ETA in the past. |
| 304 |
|
| 305 |
.. _version-2.2.4: |
| 306 |
|
| 307 |
2.2.4 |
| 308 |
===== |
| 309 |
:release-date: 2011-02-19 00:00 AM CET |
| 310 |
:release-by: Ask Solem |
| 311 |
|
| 312 |
.. _v224-fixes: |
| 313 |
|
| 314 |
Fixes |
| 315 |
----- |
| 316 |
|
| 317 |
* worker: 2.2.3 broke error logging, resulting in tracebacks not being logged. |
| 318 |
|
| 319 |
* AMQP result backend: Polling task states didn't work properly if there were |
| 320 |
more than one result message in the queue. |
| 321 |
|
| 322 |
* ``TaskSet.apply_async()`` and ``TaskSet.apply()`` now supports an optional |
| 323 |
``taskset_id`` keyword argument (Issue #331). |
| 324 |
|
| 325 |
* The current taskset id (if any) is now available in the task context as |
| 326 |
``request.taskset`` (Issue #329). |
| 327 |
|
| 328 |
* SQLAlchemy result backend: `date_done` was no longer part of the results as it had |
| 329 |
been accidentally removed. It's now available again (Issue #325). |
| 330 |
|
| 331 |
* SQLAlchemy result backend: Added unique constraint on `Task.id` and |
| 332 |
`TaskSet.taskset_id`. Tables needs to be recreated for this to take effect. |
| 333 |
|
| 334 |
* Fixed exception raised when iterating on the result of ``TaskSet.apply()``. |
| 335 |
|
| 336 |
* Tasks user guide: Added section on choosing a result backend. |
| 337 |
|
| 338 |
.. _version-2.2.3: |
| 339 |
|
| 340 |
2.2.3 |
| 341 |
===== |
| 342 |
:release-date: 2011-02-12 04:00 p.m. CET |
| 343 |
:release-by: Ask Solem |
| 344 |
|
| 345 |
.. _v223-fixes: |
| 346 |
|
| 347 |
Fixes |
| 348 |
----- |
| 349 |
|
| 350 |
* Now depends on :pypi:`Kombu` 1.0.3 |
| 351 |
|
| 352 |
* Task.retry now supports a ``max_retries`` argument, used to change the |
| 353 |
default value. |
| 354 |
|
| 355 |
* `multiprocessing.cpu_count` may raise :exc:`NotImplementedError` on |
| 356 |
platforms where this isn't supported (Issue #320). |
| 357 |
|
| 358 |
* Coloring of log messages broke if the logged object wasn't a string. |
| 359 |
|
| 360 |
* Fixed several typos in the init-script documentation. |
| 361 |
|
| 362 |
* A regression caused `Task.exchange` and `Task.routing_key` to no longer |
| 363 |
have any effect. This is now fixed. |
| 364 |
|
| 365 |
* Routing user guide: Fixes typo, routers in :setting:`CELERY_ROUTES` must be |
| 366 |
instances, not classes. |
| 367 |
|
| 368 |
* :program:`celeryev` didn't create pidfile even though the |
| 369 |
:option:`--pidfile <celery events --pidfile>` argument was set. |
| 370 |
|
| 371 |
* Task logger format was no longer used (Issue #317). |
| 372 |
|
| 373 |
The id and name of the task is now part of the log message again. |
| 374 |
|
| 375 |
* A safe version of ``repr()`` is now used in strategic places to ensure |
| 376 |
objects with a broken ``__repr__`` doesn't crash the worker, or otherwise |
| 377 |
make errors hard to understand (Issue #298). |
| 378 |
|
| 379 |
* Remote control command :control:`active_queues`: didn't account for queues added |
| 380 |
at runtime. |
| 381 |
|
| 382 |
In addition the dictionary replied by this command now has a different |
| 383 |
structure: the exchange key is now a dictionary containing the |
| 384 |
exchange declaration in full. |
| 385 |
|
| 386 |
* The :option:`celery worker -Q` option removed unused queue |
| 387 |
declarations, so routing of tasks could fail. |
| 388 |
|
| 389 |
Queues are no longer removed, but rather `app.amqp.queues.consume_from()` |
| 390 |
is used as the list of queues to consume from. |
| 391 |
|
| 392 |
This ensures all queues are available for routing purposes. |
| 393 |
|
| 394 |
* ``celeryctl``: Now supports the `inspect active_queues` command. |
| 395 |
|
| 396 |
.. _version-2.2.2: |
| 397 |
|
| 398 |
2.2.2 |
| 399 |
===== |
| 400 |
:release-date: 2011-02-03 04:00 p.m. CET |
| 401 |
:release-by: Ask Solem |
| 402 |
|
| 403 |
.. _v222-fixes: |
| 404 |
|
| 405 |
Fixes |
| 406 |
----- |
| 407 |
|
| 408 |
* ``celerybeat`` couldn't read the schedule properly, so entries in |
| 409 |
:setting:`CELERYBEAT_SCHEDULE` wouldn't be scheduled. |
| 410 |
|
| 411 |
* Task error log message now includes `exc_info` again. |
| 412 |
|
| 413 |
* The `eta` argument can now be used with `task.retry`. |
| 414 |
|
| 415 |
Previously it was overwritten by the countdown argument. |
| 416 |
|
| 417 |
* ``celery multi``/``celeryd_detach``: Now logs errors occurring when executing |
| 418 |
the `celery worker` command. |
| 419 |
|
| 420 |
* daemonizing tutorial: Fixed typo ``--time-limit 300`` -> |
| 421 |
``--time-limit=300`` |
| 422 |
|
| 423 |
* Colors in logging broke non-string objects in log messages. |
| 424 |
|
| 425 |
* ``setup_task_logger`` no longer makes assumptions about magic task kwargs. |
| 426 |
|
| 427 |
.. _version-2.2.1: |
| 428 |
|
| 429 |
2.2.1 |
| 430 |
===== |
| 431 |
:release-date: 2011-02-02 04:00 p.m. CET |
| 432 |
:release-by: Ask Solem |
| 433 |
|
| 434 |
.. _v221-fixes: |
| 435 |
|
| 436 |
Fixes |
| 437 |
----- |
| 438 |
|
| 439 |
* Eventlet pool was leaking memory (Issue #308). |
| 440 |
|
| 441 |
* Deprecated function ``celery.execute.delay_task`` was accidentally removed, |
| 442 |
now available again. |
| 443 |
|
| 444 |
* ``BasePool.on_terminate`` stub didn't exist |
| 445 |
|
| 446 |
* ``celeryd_detach``: Adds readable error messages if user/group name |
| 447 |
doesn't exist. |
| 448 |
|
| 449 |
* Smarter handling of unicode decode errors when logging errors. |
| 450 |
|
| 451 |
.. _version-2.2.0: |
| 452 |
|
| 453 |
2.2.0 |
| 454 |
===== |
| 455 |
:release-date: 2011-02-01 10:00 AM CET |
| 456 |
:release-by: Ask Solem |
| 457 |
|
| 458 |
.. _v220-important: |
| 459 |
|
| 460 |
Important Notes |
| 461 |
--------------- |
| 462 |
|
| 463 |
* Carrot has been replaced with :pypi:`Kombu` |
| 464 |
|
| 465 |
Kombu is the next generation messaging library for Python, |
| 466 |
fixing several flaws present in Carrot that was hard to fix |
| 467 |
without breaking backwards compatibility. |
| 468 |
|
| 469 |
Also it adds: |
| 470 |
|
| 471 |
* First-class support for virtual transports; Redis, Django ORM, |
| 472 |
SQLAlchemy, Beanstalk, MongoDB, CouchDB and in-memory. |
| 473 |
* Consistent error handling with introspection, |
| 474 |
* The ability to ensure that an operation is performed by gracefully |
| 475 |
handling connection and channel errors, |
| 476 |
* Message compression (:mod:`zlib`, :mod:`bz2`, or custom compression schemes). |
| 477 |
|
| 478 |
This means that `ghettoq` is no longer needed as the |
| 479 |
functionality it provided is already available in Celery by default. |
| 480 |
The virtual transports are also more feature complete with support |
| 481 |
for exchanges (direct and topic). The Redis transport even supports |
| 482 |
fanout exchanges so it's able to perform worker remote control |
| 483 |
commands. |
| 484 |
|
| 485 |
* Magic keyword arguments pending deprecation. |
| 486 |
|
| 487 |
The magic keyword arguments were responsible for many problems |
| 488 |
and quirks: notably issues with tasks and decorators, and name |
| 489 |
collisions in keyword arguments for the unaware. |
| 490 |
|
| 491 |
It wasn't easy to find a way to deprecate the magic keyword arguments, |
| 492 |
but we think this is a solution that makes sense and it won't |
| 493 |
have any adverse effects for existing code. |
| 494 |
|
| 495 |
The path to a magic keyword argument free world is: |
| 496 |
|
| 497 |
* the `celery.decorators` module is deprecated and the decorators |
| 498 |
can now be found in `celery.task`. |
| 499 |
* The decorators in `celery.task` disables keyword arguments by |
| 500 |
default |
| 501 |
* All examples in the documentation have been changed to use |
| 502 |
`celery.task`. |
| 503 |
|
| 504 |
This means that the following will have magic keyword arguments |
| 505 |
enabled (old style): |
| 506 |
|
| 507 |
.. code-block:: python |
| 508 |
|
| 509 |
from celery.decorators import task |
| 510 |
|
| 511 |
@task() |
| 512 |
def add(x, y, **kwargs): |
| 513 |
print('In task %s' % kwargs['task_id']) |
| 514 |
return x + y |
| 515 |
|
| 516 |
And this won't use magic keyword arguments (new style): |
| 517 |
|
| 518 |
.. code-block:: python |
| 519 |
|
| 520 |
from celery.task import task |
| 521 |
|
| 522 |
@task() |
| 523 |
def add(x, y): |
| 524 |
print('In task %s' % add.request.id) |
| 525 |
return x + y |
| 526 |
|
| 527 |
In addition, tasks can choose not to accept magic keyword arguments by |
| 528 |
setting the `task.accept_magic_kwargs` attribute. |
| 529 |
|
| 530 |
.. admonition:: Deprecation |
| 531 |
|
| 532 |
Using the decorators in :mod:`celery.decorators` emits a |
| 533 |
:class:`PendingDeprecationWarning` with a helpful message urging |
| 534 |
you to change your code, in version 2.4 this will be replaced with |
| 535 |
a :class:`DeprecationWarning`, and in version 4.0 the |
| 536 |
:mod:`celery.decorators` module will be removed and no longer exist. |
| 537 |
|
| 538 |
Similarly, the `task.accept_magic_kwargs` attribute will no |
| 539 |
longer have any effect starting from version 4.0. |
| 540 |
|
| 541 |
* The magic keyword arguments are now available as `task.request` |
| 542 |
|
| 543 |
This is called *the context*. Using thread-local storage the |
| 544 |
context contains state that's related to the current request. |
| 545 |
|
| 546 |
It's mutable and you can add custom attributes that'll only be seen |
| 547 |
by the current task request. |
| 548 |
|
| 549 |
The following context attributes are always available: |
| 550 |
|
| 551 |
===================================== =================================== |
| 552 |
**Magic Keyword Argument** **Replace with** |
| 553 |
===================================== =================================== |
| 554 |
`kwargs['task_id']` `self.request.id` |
| 555 |
`kwargs['delivery_info']` `self.request.delivery_info` |
| 556 |
`kwargs['task_retries']` `self.request.retries` |
| 557 |
`kwargs['logfile']` `self.request.logfile` |
| 558 |
`kwargs['loglevel']` `self.request.loglevel` |
| 559 |
`kwargs['task_is_eager']` `self.request.is_eager` |
| 560 |
**NEW** `self.request.args` |
| 561 |
**NEW** `self.request.kwargs` |
| 562 |
===================================== =================================== |
| 563 |
|
| 564 |
In addition, the following methods now automatically uses the current |
| 565 |
context, so you don't have to pass `kwargs` manually anymore: |
| 566 |
|
| 567 |
* `task.retry` |
| 568 |
* `task.get_logger` |
| 569 |
* `task.update_state` |
| 570 |
|
| 571 |
* `Eventlet`_ support. |
| 572 |
|
| 573 |
This is great news for I/O-bound tasks! |
| 574 |
|
| 575 |
To change pool implementations you use the :option:`celery worker --pool` |
| 576 |
argument, or globally using the |
| 577 |
:setting:`CELERYD_POOL` setting. This can be the full name of a class, |
| 578 |
or one of the following aliases: `processes`, `eventlet`, `gevent`. |
| 579 |
|
| 580 |
For more information please see the :ref:`concurrency-eventlet` section |
| 581 |
in the User Guide. |
| 582 |
|
| 583 |
.. admonition:: Why not gevent? |
| 584 |
|
| 585 |
For our first alternative concurrency implementation we've focused |
| 586 |
on `Eventlet`_, but there's also an experimental `gevent`_ pool |
| 587 |
available. This is missing some features, notably the ability to |
| 588 |
schedule ETA tasks. |
| 589 |
|
| 590 |
Hopefully the `gevent`_ support will be feature complete by |
| 591 |
version 2.3, but this depends on user demand (and contributions). |
| 592 |
|
| 593 |
.. _`Eventlet`: http://eventlet.net |
| 594 |
.. _`gevent`: http://gevent.org |
| 595 |
|
| 596 |
* Python 2.4 support deprecated! |
| 597 |
|
| 598 |
We're happy^H^H^H^H^Hsad to announce that this is the last version |
| 599 |
to support Python 2.4. |
| 600 |
|
| 601 |
You're urged to make some noise if you're currently stuck with |
| 602 |
Python 2.4. Complain to your package maintainers, sysadmins and bosses: |
| 603 |
tell them it's time to move on! |
| 604 |
|
| 605 |
Apart from wanting to take advantage of :keyword:`with` statements, |
| 606 |
coroutines, conditional expressions and enhanced :keyword:`try` blocks, |
| 607 |
the code base now contains so many 2.4 related hacks and workarounds |
| 608 |
it's no longer just a compromise, but a sacrifice. |
| 609 |
|
| 610 |
If it really isn't your choice, and you don't have the option to upgrade |
| 611 |
to a newer version of Python, you can just continue to use Celery 2.2. |
| 612 |
Important fixes can be back ported for as long as there's interest. |
| 613 |
|
| 614 |
* worker: Now supports Autoscaling of child worker processes. |
| 615 |
|
| 616 |
The :option:`--autoscale <celery worker --autoscale>` option can be used |
| 617 |
to configure the minimum and maximum number of child worker processes: |
| 618 |
|
| 619 |
.. code-block:: text |
| 620 |
|
| 621 |
--autoscale=AUTOSCALE |
| 622 |
Enable autoscaling by providing |
| 623 |
max_concurrency,min_concurrency. Example: |
| 624 |
--autoscale=10,3 (always keep 3 processes, but grow to |
| 625 |
10 if necessary). |
| 626 |
|
| 627 |
* Remote Debugging of Tasks |
| 628 |
|
| 629 |
``celery.contrib.rdb`` is an extended version of :mod:`pdb` that |
| 630 |
enables remote debugging of processes that doesn't have terminal |
| 631 |
access. |
| 632 |
|
| 633 |
Example usage: |
| 634 |
|
| 635 |
.. code-block:: text |
| 636 |
|
| 637 |
from celery.contrib import rdb |
| 638 |
from celery.task import task |
| 639 |
|
| 640 |
@task() |
| 641 |
def add(x, y): |
| 642 |
result = x + y |
| 643 |
# set breakpoint |
| 644 |
rdb.set_trace() |
| 645 |
return result |
| 646 |
|
| 647 |
:func:`~celery.contrib.rdb.set_trace` sets a breakpoint at the current |
| 648 |
location and creates a socket you can telnet into to remotely debug |
| 649 |
your task. |
| 650 |
|
| 651 |
The debugger may be started by multiple processes at the same time, |
| 652 |
so rather than using a fixed port the debugger will search for an |
| 653 |
available port, starting from the base port (6900 by default). |
| 654 |
The base port can be changed using the environment variable |
| 655 |
:envvar:`CELERY_RDB_PORT`. |
| 656 |
|
| 657 |
By default the debugger will only be available from the local host, |
| 658 |
to enable access from the outside you have to set the environment |
| 659 |
variable :envvar:`CELERY_RDB_HOST`. |
| 660 |
|
| 661 |
When the worker encounters your breakpoint it will log the following |
| 662 |
information:: |
| 663 |
|
| 664 |
[INFO/MainProcess] Received task: |
| 665 |
tasks.add[d7261c71-4962-47e5-b342-2448bedd20e8] |
| 666 |
[WARNING/PoolWorker-1] Remote Debugger:6900: |
| 667 |
Please telnet 127.0.0.1 6900. Type `exit` in session to continue. |
| 668 |
[2011-01-18 14:25:44,119: WARNING/PoolWorker-1] Remote Debugger:6900: |
| 669 |
Waiting for client... |
| 670 |
|
| 671 |
If you telnet the port specified you'll be presented |
| 672 |
with a ``pdb`` shell: |
| 673 |
|
| 674 |
.. code-block:: console |
| 675 |
|
| 676 |
$ telnet localhost 6900 |
| 677 |
Connected to localhost. |
| 678 |
Escape character is '^]'. |
| 679 |
> /opt/devel/demoapp/tasks.py(128)add() |
| 680 |
-> return result |
| 681 |
(Pdb) |
| 682 |
|
| 683 |
Enter ``help`` to get a list of available commands, |
| 684 |
It may be a good idea to read the `Python Debugger Manual`_ if |
| 685 |
you have never used `pdb` before. |
| 686 |
|
| 687 |
.. _`Python Debugger Manual`: http://docs.python.org/library/pdb.html |
| 688 |
|
| 689 |
|
| 690 |
* Events are now transient and is using a topic exchange (instead of direct). |
| 691 |
|
| 692 |
The `CELERYD_EVENT_EXCHANGE`, `CELERYD_EVENT_ROUTING_KEY`, |
| 693 |
`CELERYD_EVENT_EXCHANGE_TYPE` settings are no longer in use. |
| 694 |
|
| 695 |
This means events won't be stored until there's a consumer, and the |
| 696 |
events will be gone as soon as the consumer stops. Also it means there |
| 697 |
can be multiple monitors running at the same time. |
| 698 |
|
| 699 |
The routing key of an event is the type of event (e.g., `worker.started`, |
| 700 |
`worker.heartbeat`, `task.succeeded`, etc. This means a consumer can |
| 701 |
filter on specific types, to only be alerted of the events it cares about. |
| 702 |
|
| 703 |
Each consumer will create a unique queue, meaning it's in effect a |
| 704 |
broadcast exchange. |
| 705 |
|
| 706 |
This opens up a lot of possibilities, for example the workers could listen |
| 707 |
for worker events to know what workers are in the neighborhood, and even |
| 708 |
restart workers when they go down (or use this information to optimize |
| 709 |
tasks/autoscaling). |
| 710 |
|
| 711 |
.. note:: |
| 712 |
|
| 713 |
The event exchange has been renamed from ``"celeryevent"`` |
| 714 |
to ``"celeryev"`` so it doesn't collide with older versions. |
| 715 |
|
| 716 |
If you'd like to remove the old exchange you can do so |
| 717 |
by executing the following command: |
| 718 |
|
| 719 |
.. code-block:: console |
| 720 |
|
| 721 |
$ camqadm exchange.delete celeryevent |
| 722 |
|
| 723 |
* The worker now starts without configuration, and configuration can be |
| 724 |
specified directly on the command-line. |
| 725 |
|
| 726 |
Configuration options must appear after the last argument, separated |
| 727 |
by two dashes: |
| 728 |
|
| 729 |
.. code-block:: console |
| 730 |
|
| 731 |
$ celery worker -l info -I tasks -- broker.host=localhost broker.vhost=/app |
| 732 |
|
| 733 |
* Configuration is now an alias to the original configuration, so changes |
| 734 |
to the original will reflect Celery at runtime. |
| 735 |
|
| 736 |
* `celery.conf` has been deprecated, and modifying `celery.conf.ALWAYS_EAGER` |
| 737 |
will no longer have any effect. |
| 738 |
|
| 739 |
The default configuration is now available in the |
| 740 |
:mod:`celery.app.defaults` module. The available configuration options |
| 741 |
and their types can now be introspected. |
| 742 |
|
| 743 |
* Remote control commands are now provided by `kombu.pidbox`, the generic |
| 744 |
process mailbox. |
| 745 |
|
| 746 |
* Internal module `celery.worker.listener` has been renamed to |
| 747 |
`celery.worker.consumer`, and `.CarrotListener` is now `.Consumer`. |
| 748 |
|
| 749 |
* Previously deprecated modules `celery.models` and |
| 750 |
`celery.management.commands` have now been removed as per the deprecation |
| 751 |
time-line. |
| 752 |
|
| 753 |
* [Security: Low severity] Removed `celery.task.RemoteExecuteTask` and |
| 754 |
accompanying functions: `dmap`, `dmap_async`, and `execute_remote`. |
| 755 |
|
| 756 |
Executing arbitrary code using pickle is a potential security issue if |
| 757 |
someone gains unrestricted access to the message broker. |
| 758 |
|
| 759 |
If you really need this functionality, then you'd've to add |
| 760 |
this to your own project. |
| 761 |
|
| 762 |
* [Security: Low severity] The `stats` command no longer transmits the |
| 763 |
broker password. |
| 764 |
|
| 765 |
One would've needed an authenticated broker connection to receive |
| 766 |
this password in the first place, but sniffing the password at the |
| 767 |
wire level would've been possible if using unencrypted communication. |
| 768 |
|
| 769 |
.. _v220-news: |
| 770 |
|
| 771 |
News |
| 772 |
---- |
| 773 |
|
| 774 |
* The internal module `celery.task.builtins` has been removed. |
| 775 |
|
| 776 |
* The module `celery.task.schedules` is deprecated, and |
| 777 |
`celery.schedules` should be used instead. |
| 778 |
|
| 779 |
For example if you have:: |
| 780 |
|
| 781 |
from celery.task.schedules import crontab |
| 782 |
|
| 783 |
You should replace that with:: |
| 784 |
|
| 785 |
from celery.schedules import crontab |
| 786 |
|
| 787 |
The module needs to be renamed because it must be possible |
| 788 |
to import schedules without importing the `celery.task` module. |
| 789 |
|
| 790 |
* The following functions have been deprecated and is scheduled for |
| 791 |
removal in version 2.3: |
| 792 |
|
| 793 |
* `celery.execute.apply_async` |
| 794 |
|
| 795 |
Use `task.apply_async()` instead. |
| 796 |
|
| 797 |
* `celery.execute.apply` |
| 798 |
|
| 799 |
Use `task.apply()` instead. |
| 800 |
|
| 801 |
* `celery.execute.delay_task` |
| 802 |
|
| 803 |
Use `registry.tasks[name].delay()` instead. |
| 804 |
|
| 805 |
* Importing `TaskSet` from `celery.task.base` is now deprecated. |
| 806 |
|
| 807 |
You should use:: |
| 808 |
|
| 809 |
>>> from celery.task import TaskSet |
| 810 |
|
| 811 |
instead. |
| 812 |
|
| 813 |
* New remote control commands: |
| 814 |
|
| 815 |
* `active_queues` |
| 816 |
|
| 817 |
Returns the queue declarations a worker is currently consuming from. |
| 818 |
|
| 819 |
* Added the ability to retry publishing the task message in |
| 820 |
the event of connection loss or failure. |
| 821 |
|
| 822 |
This is disabled by default but can be enabled using the |
| 823 |
:setting:`CELERY_TASK_PUBLISH_RETRY` setting, and tweaked by |
| 824 |
the :setting:`CELERY_TASK_PUBLISH_RETRY_POLICY` setting. |
| 825 |
|
| 826 |
In addition `retry`, and `retry_policy` keyword arguments have |
| 827 |
been added to `Task.apply_async`. |
| 828 |
|
| 829 |
.. note:: |
| 830 |
|
| 831 |
Using the `retry` argument to `apply_async` requires you to |
| 832 |
handle the publisher/connection manually. |
| 833 |
|
| 834 |
* Periodic Task classes (`@periodic_task`/`PeriodicTask`) will *not* be |
| 835 |
deprecated as previously indicated in the source code. |
| 836 |
|
| 837 |
But you're encouraged to use the more flexible |
| 838 |
:setting:`CELERYBEAT_SCHEDULE` setting. |
| 839 |
|
| 840 |
* Built-in daemonization support of the worker using `celery multi` |
| 841 |
is no longer experimental and is considered production quality. |
| 842 |
|
| 843 |
See :ref:`daemon-generic` if you want to use the new generic init |
| 844 |
scripts. |
| 845 |
|
| 846 |
* Added support for message compression using the |
| 847 |
:setting:`CELERY_MESSAGE_COMPRESSION` setting, or the `compression` argument |
| 848 |
to `apply_async`. This can also be set using routers. |
| 849 |
|
| 850 |
* worker: Now logs stack-trace of all threads when receiving the |
| 851 |
`SIGUSR1` signal (doesn't work on CPython 2.4, Windows or Jython). |
| 852 |
|
| 853 |
Inspired by https://gist.github.com/737056 |
| 854 |
|
| 855 |
* Can now remotely terminate/kill the worker process currently processing |
| 856 |
a task. |
| 857 |
|
| 858 |
The `revoke` remote control command now supports a `terminate` argument |
| 859 |
Default signal is `TERM`, but can be specified using the `signal` |
| 860 |
argument. Signal can be the uppercase name of any signal defined |
| 861 |
in the :mod:`signal` module in the Python Standard Library. |
| 862 |
|
| 863 |
Terminating a task also revokes it. |
| 864 |
|
| 865 |
Example:: |
| 866 |
|
| 867 |
>>> from celery.task.control import revoke |
| 868 |
|
| 869 |
>>> revoke(task_id, terminate=True) |
| 870 |
>>> revoke(task_id, terminate=True, signal='KILL') |
| 871 |
>>> revoke(task_id, terminate=True, signal='SIGKILL') |
| 872 |
|
| 873 |
* `TaskSetResult.join_native`: Backend-optimized version of `join()`. |
| 874 |
|
| 875 |
If available, this version uses the backends ability to retrieve |
| 876 |
multiple results at once, unlike `join()` which fetches the results |
| 877 |
one by one. |
| 878 |
|
| 879 |
So far only supported by the AMQP result backend. Support for Memcached |
| 880 |
and Redis may be added later. |
| 881 |
|
| 882 |
* Improved implementations of `TaskSetResult.join` and `AsyncResult.wait`. |
| 883 |
|
| 884 |
An `interval` keyword argument have been added to both so the |
| 885 |
polling interval can be specified (default interval is 0.5 seconds). |
| 886 |
|
| 887 |
A `propagate` keyword argument have been added to `result.wait()`, |
| 888 |
errors will be returned instead of raised if this is set to False. |
| 889 |
|
| 890 |
.. warning:: |
| 891 |
|
| 892 |
You should decrease the polling interval when using the database |
| 893 |
result backend, as frequent polling can result in high database load. |
| 894 |
|
| 895 |
|
| 896 |
* The PID of the child worker process accepting a task is now sent as a field |
| 897 |
with the :event:`task-started` event. |
| 898 |
|
| 899 |
* The following fields have been added to all events in the worker class: |
| 900 |
|
| 901 |
* `sw_ident`: Name of worker software (e.g., ``"py-celery"``). |
| 902 |
* `sw_ver`: Software version (e.g., 2.2.0). |
| 903 |
* `sw_sys`: Operating System (e.g., Linux, Windows, Darwin). |
| 904 |
|
| 905 |
* For better accuracy the start time reported by the multiprocessing worker |
| 906 |
process is used when calculating task duration. |
| 907 |
|
| 908 |
Previously the time reported by the accept callback was used. |
| 909 |
|
| 910 |
* `celerybeat`: New built-in daemonization support using the `--detach` |
| 911 |
option. |
| 912 |
|
| 913 |
* `celeryev`: New built-in daemonization support using the `--detach` |
| 914 |
option. |
| 915 |
|
| 916 |
* `TaskSet.apply_async`: Now supports custom publishers by using the |
| 917 |
`publisher` argument. |
| 918 |
|
| 919 |
* Added :setting:`CELERY_SEND_TASK_SENT_EVENT` setting. |
| 920 |
|
| 921 |
If enabled an event will be sent with every task, so monitors can |
| 922 |
track tasks before the workers receive them. |
| 923 |
|
| 924 |
* `celerybeat`: Now reuses the broker connection when calling |
| 925 |
scheduled tasks. |
| 926 |
|
| 927 |
* The configuration module and loader to use can now be specified on |
| 928 |
the command-line. |
| 929 |
|
| 930 |
For example: |
| 931 |
|
| 932 |
.. code-block:: console |
| 933 |
|
| 934 |
$ celery worker --config=celeryconfig.py --loader=myloader.Loader |
| 935 |
|
| 936 |
* Added signals: `beat_init` and `beat_embedded_init` |
| 937 |
|
| 938 |
* :signal:`celery.signals.beat_init` |
| 939 |
|
| 940 |
Dispatched when :program:`celerybeat` starts (either standalone or |
| 941 |
embedded). Sender is the :class:`celery.beat.Service` instance. |
| 942 |
|
| 943 |
* :signal:`celery.signals.beat_embedded_init` |
| 944 |
|
| 945 |
Dispatched in addition to the :signal:`beat_init` signal when |
| 946 |
:program:`celerybeat` is started as an embedded process. Sender |
| 947 |
is the :class:`celery.beat.Service` instance. |
| 948 |
|
| 949 |
* Redis result backend: Removed deprecated settings `REDIS_TIMEOUT` and |
| 950 |
`REDIS_CONNECT_RETRY`. |
| 951 |
|
| 952 |
* CentOS init-script for :program:`celery worker` now available in `extra/centos`. |
| 953 |
|
| 954 |
* Now depends on :pypi:`pyparsing` version 1.5.0 or higher. |
| 955 |
|
| 956 |
There have been reported issues using Celery with :pypi:`pyparsing` 1.4.x, |
| 957 |
so please upgrade to the latest version. |
| 958 |
|
| 959 |
* Lots of new unit tests written, now with a total coverage of 95%. |
| 960 |
|
| 961 |
.. _v220-fixes: |
| 962 |
|
| 963 |
Fixes |
| 964 |
----- |
| 965 |
|
| 966 |
* `celeryev` Curses Monitor: Improved resize handling and UI layout |
| 967 |
(Issue #274 + Issue #276) |
| 968 |
|
| 969 |
* AMQP Backend: Exceptions occurring while sending task results are now |
| 970 |
propagated instead of silenced. |
| 971 |
|
| 972 |
the worker will then show the full traceback of these errors in the log. |
| 973 |
|
| 974 |
* AMQP Backend: No longer deletes the result queue after successful |
| 975 |
poll, as this should be handled by the |
| 976 |
:setting:`CELERY_AMQP_TASK_RESULT_EXPIRES` setting instead. |
| 977 |
|
| 978 |
* AMQP Backend: Now ensures queues are declared before polling results. |
| 979 |
|
| 980 |
* Windows: worker: Show error if running with `-B` option. |
| 981 |
|
| 982 |
Running ``celerybeat`` embedded is known not to work on Windows, so |
| 983 |
users are encouraged to run ``celerybeat`` as a separate service instead. |
| 984 |
|
| 985 |
* Windows: Utilities no longer output ANSI color codes on Windows |
| 986 |
|
| 987 |
* ``camqadm``: Now properly handles :kbd:`Control-c` by simply exiting instead |
| 988 |
of showing confusing traceback. |
| 989 |
|
| 990 |
* Windows: All tests are now passing on Windows. |
| 991 |
|
| 992 |
* Remove bin/ directory, and `scripts` section from :file:`setup.py`. |
| 993 |
|
| 994 |
This means we now rely completely on setuptools entry-points. |
| 995 |
|
| 996 |
.. _v220-experimental: |
| 997 |
|
| 998 |
Experimental |
| 999 |
------------ |
| 1000 |
|
| 1001 |
* Jython: worker now runs on Jython using the threaded pool. |
| 1002 |
|
| 1003 |
All tests pass, but there may still be bugs lurking around the corners. |
| 1004 |
|
| 1005 |
* PyPy: worker now runs on PyPy. |
| 1006 |
|
| 1007 |
It runs without any pool, so to get parallel execution you must start |
| 1008 |
multiple instances (e.g., using :program:`multi`). |
| 1009 |
|
| 1010 |
Sadly an initial benchmark seems to show a 30% performance decrease on |
| 1011 |
``pypy-1.4.1`` + JIT. We would like to find out why this is, so stay tuned. |
| 1012 |
|
| 1013 |
* :class:`PublisherPool`: Experimental pool of task publishers and |
| 1014 |
connections to be used with the `retry` argument to `apply_async`. |
| 1015 |
|
| 1016 |
The example code below will re-use connections and channels, and |
| 1017 |
retry sending of the task message if the connection is lost. |
| 1018 |
|
| 1019 |
.. code-block:: python |
| 1020 |
|
| 1021 |
from celery import current_app |
| 1022 |
|
| 1023 |
# Global pool |
| 1024 |
pool = current_app().amqp.PublisherPool(limit=10) |
| 1025 |
|
| 1026 |
def my_view(request): |
| 1027 |
with pool.acquire() as publisher: |
| 1028 |
add.apply_async((2, 2), publisher=publisher, retry=True) |