changelog-2.0.rst 33 KB

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