changelog-2.0.rst 32 KB

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