changelog-2.0.rst 32 KB

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