configuration.rst 45 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837
  1. .. _configuration:
  2. ============================
  3. Configuration and defaults
  4. ============================
  5. This document describes the configuration options available.
  6. If you're using the default loader, you must create the :file:`celeryconfig.py`
  7. module and make sure it is available on the Python path.
  8. .. contents::
  9. :local:
  10. :depth: 2
  11. .. _conf-example:
  12. Example configuration file
  13. ==========================
  14. This is an example configuration file to get you started.
  15. It should contain all you need to run a basic Celery set-up.
  16. .. code-block:: python
  17. ## Broker settings.
  18. BROKER_URL = 'amqp://guest:guest@localhost:5672//'
  19. # List of modules to import when celery starts.
  20. CELERY_IMPORTS = ('myapp.tasks', )
  21. ## Using the database to store task state and results.
  22. CELERY_RESULT_BACKEND = 'db+sqlite:///results.db'
  23. CELERY_ANNOTATIONS = {'tasks.add': {'rate_limit': '10/s'}}
  24. Configuration Directives
  25. ========================
  26. .. _conf-datetime:
  27. Time and date settings
  28. ----------------------
  29. .. setting:: CELERY_ENABLE_UTC
  30. CELERY_ENABLE_UTC
  31. ~~~~~~~~~~~~~~~~~
  32. .. versionadded:: 2.5
  33. If enabled dates and times in messages will be converted to use
  34. the UTC timezone.
  35. Note that workers running Celery versions below 2.5 will assume a local
  36. timezone for all messages, so only enable if all workers have been
  37. upgraded.
  38. Enabled by default since version 3.0.
  39. .. setting:: CELERY_TIMEZONE
  40. CELERY_TIMEZONE
  41. ~~~~~~~~~~~~~~~
  42. Configure Celery to use a custom time zone.
  43. The timezone value can be any time zone supported by the `pytz`_
  44. library.
  45. If not set the UTC timezone is used. For backwards compatibility
  46. there is also a :setting:`CELERY_ENABLE_UTC` setting, and this is set
  47. to false the system local timezone is used instead.
  48. .. _`pytz`: http://pypi.python.org/pypi/pytz/
  49. .. _conf-tasks:
  50. Task settings
  51. -------------
  52. .. setting:: CELERY_ANNOTATIONS
  53. CELERY_ANNOTATIONS
  54. ~~~~~~~~~~~~~~~~~~
  55. This setting can be used to rewrite any task attribute from the
  56. configuration. The setting can be a dict, or a list of annotation
  57. objects that filter for tasks and return a map of attributes
  58. to change.
  59. This will change the ``rate_limit`` attribute for the ``tasks.add``
  60. task:
  61. .. code-block:: python
  62. CELERY_ANNOTATIONS = {'tasks.add': {'rate_limit': '10/s'}}
  63. or change the same for all tasks:
  64. .. code-block:: python
  65. CELERY_ANNOTATIONS = {'*': {'rate_limit': '10/s'}}
  66. You can change methods too, for example the ``on_failure`` handler:
  67. .. code-block:: python
  68. def my_on_failure(self, exc, task_id, args, kwargs, einfo):
  69. print('Oh no! Task failed: {0!r}'.format(exc))
  70. CELERY_ANNOTATIONS = {'*': {'on_failure': my_on_failure}}
  71. If you need more flexibility then you can use objects
  72. instead of a dict to choose which tasks to annotate:
  73. .. code-block:: python
  74. class MyAnnotate(object):
  75. def annotate(self, task):
  76. if task.name.startswith('tasks.'):
  77. return {'rate_limit': '10/s'}
  78. CELERY_ANNOTATIONS = (MyAnnotate(), {...})
  79. .. _conf-concurrency:
  80. Concurrency settings
  81. --------------------
  82. .. setting:: CELERYD_CONCURRENCY
  83. CELERYD_CONCURRENCY
  84. ~~~~~~~~~~~~~~~~~~~
  85. The number of concurrent worker processes/threads/green threads executing
  86. tasks.
  87. If you're doing mostly I/O you can have more processes,
  88. but if mostly CPU-bound, try to keep it close to the
  89. number of CPUs on your machine. If not set, the number of CPUs/cores
  90. on the host will be used.
  91. Defaults to the number of available CPUs.
  92. .. setting:: CELERYD_PREFETCH_MULTIPLIER
  93. CELERYD_PREFETCH_MULTIPLIER
  94. ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  95. How many messages to prefetch at a time multiplied by the number of
  96. concurrent processes. The default is 4 (four messages for each
  97. process). The default setting is usually a good choice, however -- if you
  98. have very long running tasks waiting in the queue and you have to start the
  99. workers, note that the first worker to start will receive four times the
  100. number of messages initially. Thus the tasks may not be fairly distributed
  101. to the workers.
  102. .. note::
  103. Tasks with ETA/countdown are not affected by prefetch limits.
  104. .. _conf-result-backend:
  105. Task result backend settings
  106. ----------------------------
  107. .. setting:: CELERY_RESULT_BACKEND
  108. CELERY_RESULT_BACKEND
  109. ~~~~~~~~~~~~~~~~~~~~~
  110. :Deprecated aliases: ``CELERY_BACKEND``
  111. The backend used to store task results (tombstones).
  112. Disabled by default.
  113. Can be one of the following:
  114. * database
  115. Use a relational database supported by `SQLAlchemy`_.
  116. See :ref:`conf-database-result-backend`.
  117. * cache
  118. Use `memcached`_ to store the results.
  119. See :ref:`conf-cache-result-backend`.
  120. * mongodb
  121. Use `MongoDB`_ to store the results.
  122. See :ref:`conf-mongodb-result-backend`.
  123. * redis
  124. Use `Redis`_ to store the results.
  125. See :ref:`conf-redis-result-backend`.
  126. * amqp
  127. Send results back as AMQP messages
  128. See :ref:`conf-amqp-result-backend`.
  129. * cassandra
  130. Use `Cassandra`_ to store the results.
  131. See :ref:`conf-cassandra-result-backend`.
  132. * ironcache
  133. Use `IronCache`_ to store the results.
  134. See :ref:`conf-ironcache-result-backend`.
  135. * couchbase
  136. Use `Couchbase`_ to store the results.
  137. See :ref:`conf-couchbase-result-backend`.
  138. .. warning:
  139. While the AMQP result backend is very efficient, you must make sure
  140. you only receive the same result once. See :doc:`userguide/calling`).
  141. .. _`SQLAlchemy`: http://sqlalchemy.org
  142. .. _`memcached`: http://memcached.org
  143. .. _`MongoDB`: http://mongodb.org
  144. .. _`Redis`: http://redis.io
  145. .. _`Cassandra`: http://cassandra.apache.org/
  146. .. _`IronCache`: http://www.iron.io/cache
  147. .. _`Couchbase`: http://www.couchbase.com/
  148. .. setting:: CELERY_RESULT_SERIALIZER
  149. CELERY_RESULT_SERIALIZER
  150. ~~~~~~~~~~~~~~~~~~~~~~~~
  151. Result serialization format. Default is ``pickle``. See
  152. :ref:`calling-serializers` for information about supported
  153. serialization formats.
  154. .. _conf-database-result-backend:
  155. Database backend settings
  156. -------------------------
  157. Database URL Examples
  158. ~~~~~~~~~~~~~~~~~~~~~
  159. To use the database backend you have to configure the
  160. :setting:`CELERY_RESULT_BACKEND` setting with a connection URL and the ``db+``
  161. prefix:
  162. .. code-block:: python
  163. CELERY_RESULT_BACKEND = 'db+scheme://user:password@host:port/dbname'
  164. Examples:
  165. # sqlite (filename)
  166. CELERY_RESULT_BACKEND = 'db+sqlite:///results.sqlite'
  167. # mysql
  168. CELERY_RESULT_BACKEND = 'db+mysql://scott:tiger@localhost/foo'
  169. # postgresql
  170. CELERY_RESULT_BACKEND = 'db+postgresql://scott:tiger@localhost/mydatabase'
  171. # oracle
  172. CELERY_RESULT_BACKEND = 'db+oracle://scott:tiger@127.0.0.1:1521/sidname'
  173. .. code-block:: python
  174. Please see `Supported Databases`_ for a table of supported databases,
  175. and `Connection String`_ for more information about connection
  176. strings (which is the part of the URI that comes after the ``db+`` prefix).
  177. .. _`Supported Databases`:
  178. http://www.sqlalchemy.org/docs/core/engines.html#supported-databases
  179. .. _`Connection String`:
  180. http://www.sqlalchemy.org/docs/core/engines.html#database-urls
  181. .. setting:: CELERY_RESULT_DBURI
  182. CELERY_RESULT_DBURI
  183. ~~~~~~~~~~~~~~~~~~~
  184. This setting is no longer used as it's now possible to specify
  185. the database URL directly in the :setting:`CELERY_RESULT_BACKEND` setting.
  186. .. setting:: CELERY_RESULT_ENGINE_OPTIONS
  187. CELERY_RESULT_ENGINE_OPTIONS
  188. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  189. To specify additional SQLAlchemy database engine options you can use
  190. the :setting:`CELERY_RESULT_ENGINE_OPTIONS` setting::
  191. # echo enables verbose logging from SQLAlchemy.
  192. CELERY_RESULT_ENGINE_OPTIONS = {'echo': True}
  193. .. setting:: CELERY_RESULT_DB_SHORT_LIVED_SESSIONS
  194. CELERY_RESULT_DB_SHORT_LIVED_SESSIONS = True
  195. Short lived sessions are disabled by default. If enabled they can drastically reduce
  196. performance, especially on systems processing lots of tasks. This option is useful
  197. on low-traffic workers that experience errors as a result of cached database connections
  198. going stale through inactivity. For example, intermittent errors like
  199. `(OperationalError) (2006, 'MySQL server has gone away')` can be fixed by enabling
  200. short lived sessions. This option only affects the database backend.
  201. Specifying Table Names
  202. ~~~~~~~~~~~~~~~~~~~~~~
  203. .. setting:: CELERY_RESULT_DB_TABLENAMES
  204. When SQLAlchemy is configured as the result backend, Celery automatically
  205. creates two tables to store result metadata for tasks. This setting allows
  206. you to customize the table names:
  207. .. code-block:: python
  208. # use custom table names for the database result backend.
  209. CELERY_RESULT_DB_TABLENAMES = {
  210. 'task': 'myapp_taskmeta',
  211. 'group': 'myapp_groupmeta',
  212. }
  213. .. _conf-amqp-result-backend:
  214. AMQP backend settings
  215. ---------------------
  216. .. note::
  217. The AMQP backend requires RabbitMQ 1.1.0 or higher to automatically
  218. expire results. If you are running an older version of RabbitmQ
  219. you should disable result expiration like this:
  220. CELERY_TASK_RESULT_EXPIRES = None
  221. .. setting:: CELERY_RESULT_EXCHANGE
  222. CELERY_RESULT_EXCHANGE
  223. ~~~~~~~~~~~~~~~~~~~~~~
  224. Name of the exchange to publish results in. Default is `celeryresults`.
  225. .. setting:: CELERY_RESULT_EXCHANGE_TYPE
  226. CELERY_RESULT_EXCHANGE_TYPE
  227. ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  228. The exchange type of the result exchange. Default is to use a `direct`
  229. exchange.
  230. .. setting:: CELERY_RESULT_PERSISTENT
  231. CELERY_RESULT_PERSISTENT
  232. ~~~~~~~~~~~~~~~~~~~~~~~~
  233. If set to :const:`True`, result messages will be persistent. This means the
  234. messages will not be lost after a broker restart. The default is for the
  235. results to be transient.
  236. Example configuration
  237. ~~~~~~~~~~~~~~~~~~~~~
  238. .. code-block:: python
  239. CELERY_RESULT_BACKEND = 'amqp'
  240. CELERY_TASK_RESULT_EXPIRES = 18000 # 5 hours.
  241. .. _conf-cache-result-backend:
  242. Cache backend settings
  243. ----------------------
  244. .. note::
  245. The cache backend supports the `pylibmc`_ and `python-memcached`
  246. libraries. The latter is used only if `pylibmc`_ is not installed.
  247. Using a single memcached server:
  248. .. code-block:: python
  249. CELERY_RESULT_BACKEND = 'cache+memcached://127.0.0.1:11211/'
  250. Using multiple memcached servers:
  251. .. code-block:: python
  252. CELERY_RESULT_BACKEND = """
  253. cache+memcached://172.19.26.240:11211;172.19.26.242:11211/
  254. """.strip()
  255. .. setting:: CELERY_CACHE_BACKEND_OPTIONS
  256. The "memory" backend stores the cache in memory only:
  257. CELERY_CACHE_BACKEND = 'memory'
  258. CELERY_CACHE_BACKEND_OPTIONS
  259. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  260. You can set pylibmc options using the :setting:`CELERY_CACHE_BACKEND_OPTIONS`
  261. setting:
  262. .. code-block:: python
  263. CELERY_CACHE_BACKEND_OPTIONS = {'binary': True,
  264. 'behaviors': {'tcp_nodelay': True}}
  265. .. _`pylibmc`: http://sendapatch.se/projects/pylibmc/
  266. .. setting:: CELERY_CACHE_BACKEND
  267. CELERY_CACHE_BACKEND
  268. ~~~~~~~~~~~~~~~~~~~~
  269. This setting is no longer used as it's now possible to specify
  270. the cache backend directly in the :setting:`CELERY_RESULT_BACKEND` setting.
  271. .. _conf-redis-result-backend:
  272. Redis backend settings
  273. ----------------------
  274. Configuring the backend URL
  275. ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  276. .. note::
  277. The Redis backend requires the :mod:`redis` library:
  278. http://pypi.python.org/pypi/redis/
  279. To install the redis package use `pip` or `easy_install`:
  280. .. code-block:: bash
  281. $ pip install redis
  282. This backend requires the :setting:`CELERY_RESULT_BACKEND`
  283. setting to be set to a Redis URL::
  284. CELERY_RESULT_BACKEND = 'redis://:password@host:port/db'
  285. For example::
  286. CELERY_RESULT_BACKEND = 'redis://localhost/0'
  287. which is the same as::
  288. CELERY_RESULT_BACKEND = 'redis://'
  289. The fields of the URL is defined as folows:
  290. - *host*
  291. Host name or IP address of the Redis server. e.g. `localhost`.
  292. - *port*
  293. Port to the Redis server. Default is 6379.
  294. - *db*
  295. Database number to use. Default is 0.
  296. The db can include an optional leading slash.
  297. - *password*
  298. Password used to connect to the database.
  299. .. setting:: CELERY_REDIS_MAX_CONNECTIONS
  300. CELERY_REDIS_MAX_CONNECTIONS
  301. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  302. Maximum number of connections available in the Redis connection
  303. pool used for sending and retrieving results.
  304. .. _conf-mongodb-result-backend:
  305. MongoDB backend settings
  306. ------------------------
  307. .. note::
  308. The MongoDB backend requires the :mod:`pymongo` library:
  309. http://github.com/mongodb/mongo-python-driver/tree/master
  310. .. setting:: CELERY_MONGODB_BACKEND_SETTINGS
  311. CELERY_MONGODB_BACKEND_SETTINGS
  312. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  313. This is a dict supporting the following keys:
  314. * host
  315. Host name of the MongoDB server. Defaults to ``localhost``.
  316. * port
  317. The port the MongoDB server is listening to. Defaults to 27017.
  318. * user
  319. User name to authenticate to the MongoDB server as (optional).
  320. * password
  321. Password to authenticate to the MongoDB server (optional).
  322. * database
  323. The database name to connect to. Defaults to ``celery``.
  324. * taskmeta_collection
  325. The collection name to store task meta data.
  326. Defaults to ``celery_taskmeta``.
  327. * max_pool_size
  328. Passed as max_pool_size to PyMongo's Connection or MongoClient
  329. constructor. It is the maximum number of TCP connections to keep
  330. open to MongoDB at a given time. If there are more open connections
  331. than max_pool_size, sockets will be closed when they are released.
  332. Defaults to 10.
  333. * options
  334. Additional keyword arguments to pass to the mongodb connection
  335. constructor. See the :mod:`pymongo` docs to see a list of arguments
  336. supported.
  337. .. _example-mongodb-result-config:
  338. Example configuration
  339. ~~~~~~~~~~~~~~~~~~~~~
  340. .. code-block:: python
  341. CELERY_RESULT_BACKEND = 'mongodb'
  342. CELERY_MONGODB_BACKEND_SETTINGS = {
  343. 'host': '192.168.1.100',
  344. 'port': 30000,
  345. 'database': 'mydb',
  346. 'taskmeta_collection': 'my_taskmeta_collection',
  347. }
  348. .. _conf-cassandra-result-backend:
  349. Cassandra backend settings
  350. --------------------------
  351. .. note::
  352. The Cassandra backend requires the :mod:`pycassa` library:
  353. http://pypi.python.org/pypi/pycassa/
  354. To install the pycassa package use `pip` or `easy_install`:
  355. .. code-block:: bash
  356. $ pip install pycassa
  357. This backend requires the following configuration directives to be set.
  358. .. setting:: CASSANDRA_SERVERS
  359. CASSANDRA_SERVERS
  360. ~~~~~~~~~~~~~~~~~
  361. List of ``host:port`` Cassandra servers. e.g.::
  362. CASSANDRA_SERVERS = ['localhost:9160']
  363. .. setting:: CASSANDRA_KEYSPACE
  364. CASSANDRA_KEYSPACE
  365. ~~~~~~~~~~~~~~~~~~
  366. The keyspace in which to store the results. e.g.::
  367. CASSANDRA_KEYSPACE = 'tasks_keyspace'
  368. .. setting:: CASSANDRA_COLUMN_FAMILY
  369. CASSANDRA_COLUMN_FAMILY
  370. ~~~~~~~~~~~~~~~~~~~~~~~
  371. The column family in which to store the results. e.g.::
  372. CASSANDRA_COLUMN_FAMILY = 'tasks'
  373. .. setting:: CASSANDRA_READ_CONSISTENCY
  374. CASSANDRA_READ_CONSISTENCY
  375. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  376. The read consistency used. Values can be ``ONE``, ``QUORUM`` or ``ALL``.
  377. .. setting:: CASSANDRA_WRITE_CONSISTENCY
  378. CASSANDRA_WRITE_CONSISTENCY
  379. ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  380. The write consistency used. Values can be ``ONE``, ``QUORUM`` or ``ALL``.
  381. .. setting:: CASSANDRA_DETAILED_MODE
  382. CASSANDRA_DETAILED_MODE
  383. ~~~~~~~~~~~~~~~~~~~~~~~
  384. Enable or disable detailed mode. Default is :const:`False`.
  385. This mode allows to use the power of Cassandra wide columns to
  386. store all states for a task as a wide column, instead of only the last one.
  387. To use this mode, you need to configure your ColumnFamily to
  388. use the ``TimeUUID`` type as a comparator::
  389. create column family task_results with comparator = TimeUUIDType;
  390. CASSANDRA_OPTIONS
  391. ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  392. Options to be passed to the `pycassa connection pool`_ (optional).
  393. .. _`pycassa connection pool`: http://pycassa.github.com/pycassa/api/pycassa/pool.html
  394. Example configuration
  395. ~~~~~~~~~~~~~~~~~~~~~
  396. .. code-block:: python
  397. CASSANDRA_SERVERS = ['localhost:9160']
  398. CASSANDRA_KEYSPACE = 'celery'
  399. CASSANDRA_COLUMN_FAMILY = 'task_results'
  400. CASSANDRA_READ_CONSISTENCY = 'ONE'
  401. CASSANDRA_WRITE_CONSISTENCY = 'ONE'
  402. CASSANDRA_DETAILED_MODE = True
  403. CASSANDRA_OPTIONS = {
  404. 'timeout': 300,
  405. 'max_retries': 10
  406. }
  407. .. _conf-ironcache-result-backend:
  408. IronCache backend settings
  409. --------------------------
  410. .. note::
  411. The IronCache backend requires the :mod:`iron_celery` library:
  412. http://pypi.python.org/pypi/iron_celery
  413. To install the iron_celery package use `pip` or `easy_install`:
  414. .. code-block:: bash
  415. $ pip install iron_celery
  416. IronCache is configured via the URL provided in :setting:`CELERY_RESULT_BACKEND`, for example::
  417. CELERY_RESULT_BACKEND = 'ironcache://project_id:token@'
  418. Or to change the cache name::
  419. ironcache:://project_id:token@/awesomecache
  420. For more information, see: https://github.com/iron-io/iron_celery
  421. .. _conf-couchbase-result-backend:
  422. Couchbase backend settings
  423. --------------------------
  424. .. note::
  425. The Couchbase backend requires the :mod:`couchbase` library:
  426. https://pypi.python.org/pypi/couchbase
  427. To install the couchbase package use `pip` or `easy_install`:
  428. .. code-block:: bash
  429. $ pip install couchbase
  430. This backend can be configured via the :setting:`CELERY_RESULT_BACKEND`
  431. set to a couchbase URL::
  432. CELERY_RESULT_BACKEND = 'couchbase://username:password@host:port/bucket'
  433. .. setting:: CELERY_COUCHBASE_BACKEND_SETTINGS
  434. CELERY_COUCHBASE_BACKEND_SETTINGS
  435. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  436. This is a dict supporting the following keys:
  437. * host
  438. Host name of the Couchbase server. Defaults to ``localhost``.
  439. * port
  440. The port the Couchbase server is listening to. Defaults to ``8091``.
  441. * bucket
  442. The default bucket the Couchbase server is writing to.
  443. Defaults to ``default``.
  444. * username
  445. User name to authenticate to the Couchbase server as (optional).
  446. * password
  447. Password to authenticate to the Couchbase server (optional).
  448. .. _conf-messaging:
  449. Message Routing
  450. ---------------
  451. .. _conf-messaging-routing:
  452. .. setting:: CELERY_QUEUES
  453. CELERY_QUEUES
  454. ~~~~~~~~~~~~~
  455. The mapping of queues the worker consumes from. This is a dictionary
  456. of queue name/options. See :ref:`guide-routing` for more information.
  457. The default is a queue/exchange/binding key of ``celery``, with
  458. exchange type ``direct``.
  459. You don't have to care about this unless you want custom routing facilities.
  460. .. setting:: CELERY_ROUTES
  461. CELERY_ROUTES
  462. ~~~~~~~~~~~~~
  463. A list of routers, or a single router used to route tasks to queues.
  464. When deciding the final destination of a task the routers are consulted
  465. in order. See :ref:`routers` for more information.
  466. .. setting:: CELERY_QUEUE_HA_POLICY
  467. CELERY_QUEUE_HA_POLICY
  468. ~~~~~~~~~~~~~~~~~~~~~~
  469. :brokers: RabbitMQ
  470. This will set the default HA policy for a queue, and the value
  471. can either be a string (usually ``all``):
  472. .. code-block:: python
  473. CELERY_QUEUE_HA_POLICY = 'all'
  474. Using 'all' will replicate the queue to all current nodes,
  475. Or you can give it a list of nodes to replicate to:
  476. .. code-block:: python
  477. CELERY_QUEUE_HA_POLICY = ['rabbit@host1', 'rabbit@host2']
  478. Using a list will implicitly set ``x-ha-policy`` to 'nodes' and
  479. ``x-ha-policy-params`` to the given list of nodes.
  480. See http://www.rabbitmq.com/ha.html for more information.
  481. .. setting:: CELERY_WORKER_DIRECT
  482. CELERY_WORKER_DIRECT
  483. ~~~~~~~~~~~~~~~~~~~~
  484. This option enables so that every worker has a dedicated queue,
  485. so that tasks can be routed to specific workers.
  486. The queue name for each worker is automatically generated based on
  487. the worker hostname and a ``.dq`` suffix, using the ``C.dq`` exchange.
  488. For example the queue name for the worker with hostname ``w1.example.com``
  489. becomes::
  490. w1.example.com.dq
  491. Then you can route the task to the task by specifying the hostname
  492. as the routing key and the ``C.dq`` exchange::
  493. CELERY_ROUTES = {
  494. 'tasks.add': {'exchange': 'C.dq', 'routing_key': 'w1.example.com'}
  495. }
  496. .. setting:: CELERY_CREATE_MISSING_QUEUES
  497. CELERY_CREATE_MISSING_QUEUES
  498. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  499. If enabled (default), any queues specified that are not defined in
  500. :setting:`CELERY_QUEUES` will be automatically created. See
  501. :ref:`routing-automatic`.
  502. .. setting:: CELERY_DEFAULT_QUEUE
  503. CELERY_DEFAULT_QUEUE
  504. ~~~~~~~~~~~~~~~~~~~~
  505. The name of the default queue used by `.apply_async` if the message has
  506. no route or no custom queue has been specified.
  507. This queue must be listed in :setting:`CELERY_QUEUES`.
  508. If :setting:`CELERY_QUEUES` is not specified then it is automatically
  509. created containing one queue entry, where this name is used as the name of
  510. that queue.
  511. The default is: `celery`.
  512. .. seealso::
  513. :ref:`routing-changing-default-queue`
  514. .. setting:: CELERY_DEFAULT_EXCHANGE
  515. CELERY_DEFAULT_EXCHANGE
  516. ~~~~~~~~~~~~~~~~~~~~~~~
  517. Name of the default exchange to use when no custom exchange is
  518. specified for a key in the :setting:`CELERY_QUEUES` setting.
  519. The default is: `celery`.
  520. .. setting:: CELERY_DEFAULT_EXCHANGE_TYPE
  521. CELERY_DEFAULT_EXCHANGE_TYPE
  522. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  523. Default exchange type used when no custom exchange type is specified
  524. for a key in the :setting:`CELERY_QUEUES` setting.
  525. The default is: `direct`.
  526. .. setting:: CELERY_DEFAULT_ROUTING_KEY
  527. CELERY_DEFAULT_ROUTING_KEY
  528. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  529. The default routing key used when no custom routing key
  530. is specified for a key in the :setting:`CELERY_QUEUES` setting.
  531. The default is: `celery`.
  532. .. setting:: CELERY_DEFAULT_DELIVERY_MODE
  533. CELERY_DEFAULT_DELIVERY_MODE
  534. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  535. Can be `transient` or `persistent`. The default is to send
  536. persistent messages.
  537. .. _conf-broker-settings:
  538. Broker Settings
  539. ---------------
  540. .. setting:: CELERY_ACCEPT_CONTENT
  541. CELERY_ACCEPT_CONTENT
  542. ~~~~~~~~~~~~~~~~~~~~~
  543. A whitelist of content-types/serializers to allow.
  544. If a message is received that is not in this list then
  545. the message will be discarded with an error.
  546. By default any content type is enabled (including pickle and yaml)
  547. so make sure untrusted parties do not have access to your broker.
  548. See :ref:`guide-security` for more.
  549. Example::
  550. # using serializer name
  551. CELERY_ACCEPT_CONTENT = ['json']
  552. # or the actual content-type (MIME)
  553. CELERY_ACCEPT_CONTENT = ['application/json']
  554. .. setting:: BROKER_TRANSPORT
  555. BROKER_TRANSPORT
  556. ~~~~~~~~~~~~~~~~
  557. :Aliases: ``BROKER_BACKEND``
  558. :Deprecated aliases: ``CARROT_BACKEND``
  559. .. setting:: BROKER_URL
  560. BROKER_URL
  561. ~~~~~~~~~~
  562. Default broker URL. This must be an URL in the form of::
  563. transport://userid:password@hostname:port/virtual_host
  564. Only the scheme part (``transport://``) is required, the rest
  565. is optional, and defaults to the specific transports default values.
  566. The transport part is the broker implementation to use, and the
  567. default is ``amqp``, which uses ``librabbitmq`` by default or falls back to
  568. ``pyamqp`` if that is not installed. Also there are many other choices including
  569. ``redis``, ``beanstalk``, ``sqlalchemy``, ``django``, ``mongodb``,
  570. ``couchdb``.
  571. It can also be a fully qualified path to your own transport implementation.
  572. See :ref:`kombu:connection-urls` in the Kombu documentation for more
  573. information.
  574. .. setting:: BROKER_HEARTBEAT
  575. BROKER_HEARTBEAT
  576. ~~~~~~~~~~~~~~~~
  577. :transports supported: ``pyamqp``
  578. It's not always possible to detect connection loss in a timely
  579. manner using TCP/IP alone, so AMQP defines something called heartbeats
  580. that's is used both by the client and the broker to detect if
  581. a connection was closed.
  582. Hartbeats are disabled by default.
  583. If the heartbeat value is 10 seconds, then
  584. the heartbeat will be monitored at the interval specified
  585. by the :setting:`BROKER_HEARTBEAT_CHECKRATE` setting, which by default is
  586. double the rate of the heartbeat value
  587. (so for the default 10 seconds, the heartbeat is checked every 5 seconds).
  588. .. setting:: BROKER_HEARTBEAT_CHECKRATE
  589. BROKER_HEARTBEAT_CHECKRATE
  590. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  591. :transports supported: ``pyamqp``
  592. At intervals the worker will monitor that the broker has not missed
  593. too many heartbeats. The rate at which this is checked is calculated
  594. by dividing the :setting:`BROKER_HEARTBEAT` value with this value,
  595. so if the heartbeat is 10.0 and the rate is the default 2.0, the check
  596. will be performed every 5 seconds (twice the heartbeat sending rate).
  597. .. setting:: BROKER_USE_SSL
  598. BROKER_USE_SSL
  599. ~~~~~~~~~~~~~~
  600. Use SSL to connect to the broker. Off by default. This may not be supported
  601. by all transports.
  602. .. setting:: BROKER_POOL_LIMIT
  603. BROKER_POOL_LIMIT
  604. ~~~~~~~~~~~~~~~~~
  605. .. versionadded:: 2.3
  606. The maximum number of connections that can be open in the connection pool.
  607. The pool is enabled by default since version 2.5, with a default limit of ten
  608. connections. This number can be tweaked depending on the number of
  609. threads/greenthreads (eventlet/gevent) using a connection. For example
  610. running eventlet with 1000 greenlets that use a connection to the broker,
  611. contention can arise and you should consider increasing the limit.
  612. If set to :const:`None` or 0 the connection pool will be disabled and
  613. connections will be established and closed for every use.
  614. Default (since 2.5) is to use a pool of 10 connections.
  615. .. setting:: BROKER_CONNECTION_TIMEOUT
  616. BROKER_CONNECTION_TIMEOUT
  617. ~~~~~~~~~~~~~~~~~~~~~~~~~
  618. The default timeout in seconds before we give up establishing a connection
  619. to the AMQP server. Default is 4 seconds.
  620. .. setting:: BROKER_CONNECTION_RETRY
  621. BROKER_CONNECTION_RETRY
  622. ~~~~~~~~~~~~~~~~~~~~~~~
  623. Automatically try to re-establish the connection to the AMQP broker if lost.
  624. The time between retries is increased for each retry, and is
  625. not exhausted before :setting:`BROKER_CONNECTION_MAX_RETRIES` is
  626. exceeded.
  627. This behavior is on by default.
  628. .. setting:: BROKER_CONNECTION_MAX_RETRIES
  629. BROKER_CONNECTION_MAX_RETRIES
  630. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  631. Maximum number of retries before we give up re-establishing a connection
  632. to the AMQP broker.
  633. If this is set to :const:`0` or :const:`None`, we will retry forever.
  634. Default is 100 retries.
  635. .. setting:: BROKER_LOGIN_METHOD
  636. BROKER_LOGIN_METHOD
  637. ~~~~~~~~~~~~~~~~~~~
  638. Set custom amqp login method, default is ``AMQPLAIN``.
  639. .. setting:: BROKER_TRANSPORT_OPTIONS
  640. BROKER_TRANSPORT_OPTIONS
  641. ~~~~~~~~~~~~~~~~~~~~~~~~
  642. .. versionadded:: 2.2
  643. A dict of additional options passed to the underlying transport.
  644. See your transport user manual for supported options (if any).
  645. Example setting the visibility timeout (supported by Redis and SQS
  646. transports):
  647. .. code-block:: python
  648. BROKER_TRANSPORT_OPTIONS = {'visibility_timeout': 18000} # 5 hours
  649. .. _conf-task-execution:
  650. Task execution settings
  651. -----------------------
  652. .. setting:: CELERY_ALWAYS_EAGER
  653. CELERY_ALWAYS_EAGER
  654. ~~~~~~~~~~~~~~~~~~~
  655. If this is :const:`True`, all tasks will be executed locally by blocking until
  656. the task returns. ``apply_async()`` and ``Task.delay()`` will return
  657. an :class:`~celery.result.EagerResult` instance, which emulates the API
  658. and behavior of :class:`~celery.result.AsyncResult`, except the result
  659. is already evaluated.
  660. That is, tasks will be executed locally instead of being sent to
  661. the queue.
  662. .. setting:: CELERY_EAGER_PROPAGATES_EXCEPTIONS
  663. CELERY_EAGER_PROPAGATES_EXCEPTIONS
  664. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  665. If this is :const:`True`, eagerly executed tasks (applied by `task.apply()`,
  666. or when the :setting:`CELERY_ALWAYS_EAGER` setting is enabled), will
  667. propagate exceptions.
  668. It's the same as always running ``apply()`` with ``throw=True``.
  669. .. setting:: CELERY_IGNORE_RESULT
  670. CELERY_IGNORE_RESULT
  671. ~~~~~~~~~~~~~~~~~~~~
  672. Whether to store the task return values or not (tombstones).
  673. If you still want to store errors, just not successful return values,
  674. you can set :setting:`CELERY_STORE_ERRORS_EVEN_IF_IGNORED`.
  675. .. setting:: CELERY_MESSAGE_COMPRESSION
  676. CELERY_MESSAGE_COMPRESSION
  677. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  678. Default compression used for task messages.
  679. Can be ``gzip``, ``bzip2`` (if available), or any custom
  680. compression schemes registered in the Kombu compression registry.
  681. The default is to send uncompressed messages.
  682. .. setting:: CELERY_TASK_RESULT_EXPIRES
  683. CELERY_TASK_RESULT_EXPIRES
  684. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  685. Time (in seconds, or a :class:`~datetime.timedelta` object) for when after
  686. stored task tombstones will be deleted.
  687. A built-in periodic task will delete the results after this time
  688. (:class:`celery.task.backend_cleanup`).
  689. A value of :const:`None` or 0 means results will never expire (depending
  690. on backend specifications).
  691. Default is to expire after 1 day.
  692. .. note::
  693. For the moment this only works with the amqp, database, cache, redis and MongoDB
  694. backends.
  695. When using the database or MongoDB backends, `celery beat` must be
  696. running for the results to be expired.
  697. .. setting:: CELERY_MAX_CACHED_RESULTS
  698. CELERY_MAX_CACHED_RESULTS
  699. ~~~~~~~~~~~~~~~~~~~~~~~~~
  700. Result backends caches ready results used by the client.
  701. This is the total number of results to cache before older results are evicted.
  702. The default is 5000.
  703. .. setting:: CELERY_CHORD_PROPAGATES
  704. CELERY_CHORD_PROPAGATES
  705. ~~~~~~~~~~~~~~~~~~~~~~~
  706. .. versionadded:: 3.0.14
  707. This setting defines what happens when a task part of a chord raises an
  708. exception:
  709. - If propagate is True the chord callback will change state to FAILURE
  710. with the exception value set to a :exc:`~celery.exceptions.ChordError`
  711. instance containing information about the error and the task that failed.
  712. This is the default behavior in Celery 3.1+
  713. - If propagate is False the exception value will instead be forwarded
  714. to the chord callback.
  715. This was the default behavior before version 3.1.
  716. .. setting:: CELERY_TRACK_STARTED
  717. CELERY_TRACK_STARTED
  718. ~~~~~~~~~~~~~~~~~~~~
  719. If :const:`True` the task will report its status as "started" when the
  720. task is executed by a worker. The default value is :const:`False` as
  721. the normal behaviour is to not report that level of granularity. Tasks
  722. are either pending, finished, or waiting to be retried. Having a "started"
  723. state can be useful for when there are long running tasks and there is a
  724. need to report which task is currently running.
  725. .. setting:: CELERY_TASK_SERIALIZER
  726. CELERY_TASK_SERIALIZER
  727. ~~~~~~~~~~~~~~~~~~~~~~
  728. A string identifying the default serialization method to use. Can be
  729. `pickle` (default), `json`, `yaml`, `msgpack` or any custom serialization
  730. methods that have been registered with :mod:`kombu.serialization.registry`.
  731. .. seealso::
  732. :ref:`calling-serializers`.
  733. .. setting:: CELERY_TASK_PUBLISH_RETRY
  734. CELERY_TASK_PUBLISH_RETRY
  735. ~~~~~~~~~~~~~~~~~~~~~~~~~
  736. .. versionadded:: 2.2
  737. Decides if publishing task messages will be retried in the case
  738. of connection loss or other connection errors.
  739. See also :setting:`CELERY_TASK_PUBLISH_RETRY_POLICY`.
  740. Enabled by default.
  741. .. setting:: CELERY_TASK_PUBLISH_RETRY_POLICY
  742. CELERY_TASK_PUBLISH_RETRY_POLICY
  743. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  744. .. versionadded:: 2.2
  745. Defines the default policy when retrying publishing a task message in
  746. the case of connection loss or other connection errors.
  747. See :ref:`calling-retry` for more information.
  748. .. setting:: CELERY_DEFAULT_RATE_LIMIT
  749. CELERY_DEFAULT_RATE_LIMIT
  750. ~~~~~~~~~~~~~~~~~~~~~~~~~
  751. The global default rate limit for tasks.
  752. This value is used for tasks that does not have a custom rate limit
  753. The default is no rate limit.
  754. .. setting:: CELERY_DISABLE_RATE_LIMITS
  755. CELERY_DISABLE_RATE_LIMITS
  756. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  757. Disable all rate limits, even if tasks has explicit rate limits set.
  758. .. setting:: CELERY_ACKS_LATE
  759. CELERY_ACKS_LATE
  760. ~~~~~~~~~~~~~~~~
  761. Late ack means the task messages will be acknowledged **after** the task
  762. has been executed, not *just before*, which is the default behavior.
  763. .. seealso::
  764. FAQ: :ref:`faq-acks_late-vs-retry`.
  765. .. _conf-worker:
  766. Worker
  767. ------
  768. .. setting:: CELERY_IMPORTS
  769. CELERY_IMPORTS
  770. ~~~~~~~~~~~~~~
  771. A sequence of modules to import when the worker starts.
  772. This is used to specify the task modules to import, but also
  773. to import signal handlers and additional remote control commands, etc.
  774. The modules will be imported in the original order.
  775. .. setting:: CELERY_INCLUDE
  776. CELERY_INCLUDE
  777. ~~~~~~~~~~~~~~
  778. Exact same semantics as :setting:`CELERY_IMPORTS`, but can be used as a means
  779. to have different import categories.
  780. The modules in this setting are imported after the modules in
  781. :setting:`CELERY_IMPORTS`.
  782. .. setting:: CELERYD_FORCE_EXECV
  783. CELERYD_FORCE_EXECV
  784. ~~~~~~~~~~~~~~~~~~~
  785. On Unix the processes pool will fork, so that child processes
  786. start with the same memory as the parent process.
  787. This can cause problems as there is a known deadlock condition
  788. with pthread locking primitives when `fork()` is combined with threads.
  789. You should enable this setting if you are experiencing hangs (deadlocks),
  790. especially in combination with time limits or having a max tasks per child limit.
  791. This option will be enabled by default in a later version.
  792. This is not a problem on Windows, as it does not have `fork()`.
  793. .. setting:: CELERYD_WORKER_LOST_WAIT
  794. CELERYD_WORKER_LOST_WAIT
  795. ~~~~~~~~~~~~~~~~~~~~~~~~
  796. In some cases a worker may be killed without proper cleanup,
  797. and the worker may have published a result before terminating.
  798. This value specifies how long we wait for any missing results before
  799. raising a :exc:`@WorkerLostError` exception.
  800. Default is 10.0
  801. .. setting:: CELERYD_MAX_TASKS_PER_CHILD
  802. CELERYD_MAX_TASKS_PER_CHILD
  803. ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  804. Maximum number of tasks a pool worker process can execute before
  805. it's replaced with a new one. Default is no limit.
  806. .. setting:: CELERYD_TASK_TIME_LIMIT
  807. CELERYD_TASK_TIME_LIMIT
  808. ~~~~~~~~~~~~~~~~~~~~~~~
  809. Task hard time limit in seconds. The worker processing the task will
  810. be killed and replaced with a new one when this is exceeded.
  811. .. setting:: CELERYD_TASK_SOFT_TIME_LIMIT
  812. CELERYD_TASK_SOFT_TIME_LIMIT
  813. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  814. Task soft time limit in seconds.
  815. The :exc:`~@SoftTimeLimitExceeded` exception will be
  816. raised when this is exceeded. The task can catch this to
  817. e.g. clean up before the hard time limit comes.
  818. Example:
  819. .. code-block:: python
  820. from celery.exceptions import SoftTimeLimitExceeded
  821. @celery.task
  822. def mytask():
  823. try:
  824. return do_work()
  825. except SoftTimeLimitExceeded:
  826. cleanup_in_a_hurry()
  827. .. setting:: CELERY_STORE_ERRORS_EVEN_IF_IGNORED
  828. CELERY_STORE_ERRORS_EVEN_IF_IGNORED
  829. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  830. If set, the worker stores all task errors in the result store even if
  831. :attr:`Task.ignore_result <celery.task.base.Task.ignore_result>` is on.
  832. .. setting:: CELERYD_STATE_DB
  833. CELERYD_STATE_DB
  834. ~~~~~~~~~~~~~~~~
  835. Name of the file used to stores persistent worker state (like revoked tasks).
  836. Can be a relative or absolute path, but be aware that the suffix `.db`
  837. may be appended to the file name (depending on Python version).
  838. Can also be set via the :option:`--statedb` argument to
  839. :mod:`~celery.bin.worker`.
  840. Not enabled by default.
  841. .. setting:: CELERYD_TIMER_PRECISION
  842. CELERYD_TIMER_PRECISION
  843. ~~~~~~~~~~~~~~~~~~~~~~~
  844. Set the maximum time in seconds that the ETA scheduler can sleep between
  845. rechecking the schedule. Default is 1 second.
  846. Setting this value to 1 second means the schedulers precision will
  847. be 1 second. If you need near millisecond precision you can set this to 0.1.
  848. .. setting:: CELERY_ENABLE_REMOTE_CONTROL
  849. CELERY_ENABLE_REMOTE_CONTROL
  850. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  851. Specify if remote control of the workers is enabled.
  852. Default is :const:`True`.
  853. .. _conf-error-mails:
  854. Error E-Mails
  855. -------------
  856. .. setting:: CELERY_SEND_TASK_ERROR_EMAILS
  857. CELERY_SEND_TASK_ERROR_EMAILS
  858. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  859. The default value for the `Task.send_error_emails` attribute, which if
  860. set to :const:`True` means errors occurring during task execution will be
  861. sent to :setting:`ADMINS` by email.
  862. Disabled by default.
  863. .. setting:: ADMINS
  864. ADMINS
  865. ~~~~~~
  866. List of `(name, email_address)` tuples for the administrators that should
  867. receive error emails.
  868. .. setting:: SERVER_EMAIL
  869. SERVER_EMAIL
  870. ~~~~~~~~~~~~
  871. The email address this worker sends emails from.
  872. Default is celery@localhost.
  873. .. setting:: EMAIL_HOST
  874. EMAIL_HOST
  875. ~~~~~~~~~~
  876. The mail server to use. Default is ``localhost``.
  877. .. setting:: EMAIL_HOST_USER
  878. EMAIL_HOST_USER
  879. ~~~~~~~~~~~~~~~
  880. User name (if required) to log on to the mail server with.
  881. .. setting:: EMAIL_HOST_PASSWORD
  882. EMAIL_HOST_PASSWORD
  883. ~~~~~~~~~~~~~~~~~~~
  884. Password (if required) to log on to the mail server with.
  885. .. setting:: EMAIL_PORT
  886. EMAIL_PORT
  887. ~~~~~~~~~~
  888. The port the mail server is listening on. Default is `25`.
  889. .. setting:: EMAIL_USE_SSL
  890. EMAIL_USE_SSL
  891. ~~~~~~~~~~~~~
  892. Use SSL when connecting to the SMTP server. Disabled by default.
  893. .. setting:: EMAIL_USE_TLS
  894. EMAIL_USE_TLS
  895. ~~~~~~~~~~~~~
  896. Use TLS when connecting to the SMTP server. Disabled by default.
  897. .. setting:: EMAIL_TIMEOUT
  898. EMAIL_TIMEOUT
  899. ~~~~~~~~~~~~~
  900. Timeout in seconds for when we give up trying to connect
  901. to the SMTP server when sending emails.
  902. The default is 2 seconds.
  903. .. _conf-example-error-mail-config:
  904. Example E-Mail configuration
  905. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  906. This configuration enables the sending of error emails to
  907. george@vandelay.com and kramer@vandelay.com:
  908. .. code-block:: python
  909. # Enables error emails.
  910. CELERY_SEND_TASK_ERROR_EMAILS = True
  911. # Name and email addresses of recipients
  912. ADMINS = (
  913. ('George Costanza', 'george@vandelay.com'),
  914. ('Cosmo Kramer', 'kosmo@vandelay.com'),
  915. )
  916. # Email address used as sender (From field).
  917. SERVER_EMAIL = 'no-reply@vandelay.com'
  918. # Mailserver configuration
  919. EMAIL_HOST = 'mail.vandelay.com'
  920. EMAIL_PORT = 25
  921. # EMAIL_HOST_USER = 'servers'
  922. # EMAIL_HOST_PASSWORD = 's3cr3t'
  923. .. _conf-events:
  924. Events
  925. ------
  926. .. setting:: CELERY_SEND_EVENTS
  927. CELERY_SEND_EVENTS
  928. ~~~~~~~~~~~~~~~~~~
  929. Send events so the worker can be monitored by tools like `celerymon`.
  930. .. setting:: CELERY_SEND_TASK_SENT_EVENT
  931. CELERY_SEND_TASK_SENT_EVENT
  932. ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  933. .. versionadded:: 2.2
  934. If enabled, a :event:`task-sent` event will be sent for every task so tasks can be
  935. tracked before they are consumed by a worker.
  936. Disabled by default.
  937. .. setting:: CELERY_EVENT_QUEUE_TTL
  938. CELERY_EVENT_QUEUE_TTL
  939. ~~~~~~~~~~~~~~~~~~~~~~
  940. :transports supported: ``amqp``
  941. Message expiry time in seconds (int/float) for when messages sent to a monitor clients
  942. event queue is deleted (``x-message-ttl``)
  943. For example, if this value is set to 10 then a message delivered to this queue
  944. will be deleted after 10 seconds.
  945. Disabled by default.
  946. .. setting:: CELERY_EVENT_QUEUE_EXPIRES
  947. CELERY_EVENT_QUEUE_EXPIRES
  948. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  949. :transports supported: ``amqp``
  950. Expiry time in seconds (int/float) for when a monitor clients
  951. event queue will be deleted (``x-expires``).
  952. Default is never, relying on the queue autodelete setting.
  953. .. setting:: CELERY_EVENT_SERIALIZER
  954. CELERY_EVENT_SERIALIZER
  955. ~~~~~~~~~~~~~~~~~~~~~~~
  956. Message serialization format used when sending event messages.
  957. Default is ``json``. See :ref:`calling-serializers`.
  958. .. _conf-broadcast:
  959. Broadcast Commands
  960. ------------------
  961. .. setting:: CELERY_BROADCAST_QUEUE
  962. CELERY_BROADCAST_QUEUE
  963. ~~~~~~~~~~~~~~~~~~~~~~
  964. Name prefix for the queue used when listening for broadcast messages.
  965. The workers host name will be appended to the prefix to create the final
  966. queue name.
  967. Default is ``celeryctl``.
  968. .. setting:: CELERY_BROADCAST_EXCHANGE
  969. CELERY_BROADCAST_EXCHANGE
  970. ~~~~~~~~~~~~~~~~~~~~~~~~~
  971. Name of the exchange used for broadcast messages.
  972. Default is ``celeryctl``.
  973. .. setting:: CELERY_BROADCAST_EXCHANGE_TYPE
  974. CELERY_BROADCAST_EXCHANGE_TYPE
  975. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  976. Exchange type used for broadcast messages. Default is ``fanout``.
  977. .. _conf-logging:
  978. Logging
  979. -------
  980. .. setting:: CELERYD_HIJACK_ROOT_LOGGER
  981. CELERYD_HIJACK_ROOT_LOGGER
  982. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  983. .. versionadded:: 2.2
  984. By default any previously configured handlers on the root logger will be
  985. removed. If you want to customize your own logging handlers, then you
  986. can disable this behavior by setting
  987. `CELERYD_HIJACK_ROOT_LOGGER = False`.
  988. .. note::
  989. Logging can also be customized by connecting to the
  990. :signal:`celery.signals.setup_logging` signal.
  991. .. setting:: CELERYD_LOG_COLOR
  992. CELERYD_LOG_COLOR
  993. ~~~~~~~~~~~~~~~~~
  994. Enables/disables colors in logging output by the Celery apps.
  995. By default colors are enabled if
  996. 1) the app is logging to a real terminal, and not a file.
  997. 2) the app is not running on Windows.
  998. .. setting:: CELERYD_LOG_FORMAT
  999. CELERYD_LOG_FORMAT
  1000. ~~~~~~~~~~~~~~~~~~
  1001. The format to use for log messages.
  1002. Default is `[%(asctime)s: %(levelname)s/%(processName)s] %(message)s`
  1003. See the Python :mod:`logging` module for more information about log
  1004. formats.
  1005. .. setting:: CELERYD_TASK_LOG_FORMAT
  1006. CELERYD_TASK_LOG_FORMAT
  1007. ~~~~~~~~~~~~~~~~~~~~~~~
  1008. The format to use for log messages logged in tasks. Can be overridden using
  1009. the :option:`--loglevel` option to :mod:`~celery.bin.worker`.
  1010. Default is::
  1011. [%(asctime)s: %(levelname)s/%(processName)s]
  1012. [%(task_name)s(%(task_id)s)] %(message)s
  1013. See the Python :mod:`logging` module for more information about log
  1014. formats.
  1015. .. setting:: CELERY_REDIRECT_STDOUTS
  1016. CELERY_REDIRECT_STDOUTS
  1017. ~~~~~~~~~~~~~~~~~~~~~~~
  1018. If enabled `stdout` and `stderr` will be redirected
  1019. to the current logger.
  1020. Enabled by default.
  1021. Used by :program:`celery worker` and :program:`celery beat`.
  1022. .. setting:: CELERY_REDIRECT_STDOUTS_LEVEL
  1023. CELERY_REDIRECT_STDOUTS_LEVEL
  1024. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1025. The log level output to `stdout` and `stderr` is logged as.
  1026. Can be one of :const:`DEBUG`, :const:`INFO`, :const:`WARNING`,
  1027. :const:`ERROR` or :const:`CRITICAL`.
  1028. Default is :const:`WARNING`.
  1029. .. setting:: CELERY_FORCE_BILLIARD_LOGGING
  1030. CELERY_FORCE_BILLIARD_LOGGING
  1031. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1032. .. versionadded:: 3.1
  1033. Celery uses :mod:`multiprocessing`'s fork called `billiard` as a pool
  1034. implementation. Python assumes we use :mod:`multiprocessing` when trying
  1035. to log `processName` though. By default this option forces Celery to modify
  1036. the logger class as early as possible in order to provide correct process
  1037. name in log messages. If you are going to use :mod:`multiprocessing` along
  1038. with Celery, you can disable this behavior by setting
  1039. `CELERY_FORCE_BILLIARD_LOGGING = False`.
  1040. Default is :const:`True`.
  1041. .. _conf-security:
  1042. Security
  1043. --------
  1044. .. setting:: CELERY_SECURITY_KEY
  1045. CELERY_SECURITY_KEY
  1046. ~~~~~~~~~~~~~~~~~~~
  1047. .. versionadded:: 2.5
  1048. The relative or absolute path to a file containing the private key
  1049. used to sign messages when :ref:`message-signing` is used.
  1050. .. setting:: CELERY_SECURITY_CERTIFICATE
  1051. CELERY_SECURITY_CERTIFICATE
  1052. ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1053. .. versionadded:: 2.5
  1054. The relative or absolute path to an X.509 certificate file
  1055. used to sign messages when :ref:`message-signing` is used.
  1056. .. setting:: CELERY_SECURITY_CERT_STORE
  1057. CELERY_SECURITY_CERT_STORE
  1058. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  1059. .. versionadded:: 2.5
  1060. The directory containing X.509 certificates used for
  1061. :ref:`message-signing`. Can be a glob with wildcards,
  1062. (for example :file:`/etc/certs/*.pem`).
  1063. .. _conf-custom-components:
  1064. Custom Component Classes (advanced)
  1065. -----------------------------------
  1066. .. setting:: CELERYD_POOL
  1067. CELERYD_POOL
  1068. ~~~~~~~~~~~~
  1069. Name of the pool class used by the worker.
  1070. You can use a custom pool class name, or select one of
  1071. the built-in aliases: ``processes``, ``eventlet``, ``gevent``.
  1072. Default is ``processes``.
  1073. .. setting:: CELERYD_POOL_RESTARTS
  1074. CELERYD_POOL_RESTARTS
  1075. ~~~~~~~~~~~~~~~~~~~~~
  1076. If enabled the worker pool can be restarted using the
  1077. :control:`pool_restart` remote control command.
  1078. Disabled by default.
  1079. .. setting:: CELERYD_AUTOSCALER
  1080. CELERYD_AUTOSCALER
  1081. ~~~~~~~~~~~~~~~~~~
  1082. .. versionadded:: 2.2
  1083. Name of the autoscaler class to use.
  1084. Default is ``celery.worker.autoscale:Autoscaler``.
  1085. .. setting:: CELERYD_AUTORELOADER
  1086. CELERYD_AUTORELOADER
  1087. ~~~~~~~~~~~~~~~~~~~~
  1088. Name of the autoreloader class used by the worker to reload
  1089. Python modules and files that have changed.
  1090. Default is: ``celery.worker.autoreload:Autoreloader``.
  1091. .. setting:: CELERYD_CONSUMER
  1092. CELERYD_CONSUMER
  1093. ~~~~~~~~~~~~~~~~
  1094. Name of the consumer class used by the worker.
  1095. Default is :class:`celery.worker.consumer.Consumer`
  1096. .. setting:: CELERYD_TIMER
  1097. CELERYD_TIMER
  1098. ~~~~~~~~~~~~~~~~~~~~~
  1099. Name of the ETA scheduler class used by the worker.
  1100. Default is :class:`celery.utils.timer2.Timer`, or one overrided
  1101. by the pool implementation.
  1102. .. _conf-celerybeat:
  1103. Periodic Task Server: celery beat
  1104. ---------------------------------
  1105. .. setting:: CELERYBEAT_SCHEDULE
  1106. CELERYBEAT_SCHEDULE
  1107. ~~~~~~~~~~~~~~~~~~~
  1108. The periodic task schedule used by :mod:`~celery.bin.beat`.
  1109. See :ref:`beat-entries`.
  1110. .. setting:: CELERYBEAT_SCHEDULER
  1111. CELERYBEAT_SCHEDULER
  1112. ~~~~~~~~~~~~~~~~~~~~
  1113. The default scheduler class. Default is ``celery.beat:PersistentScheduler``.
  1114. Can also be set via the :option:`-S` argument to
  1115. :mod:`~celery.bin.beat`.
  1116. .. setting:: CELERYBEAT_SCHEDULE_FILENAME
  1117. CELERYBEAT_SCHEDULE_FILENAME
  1118. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1119. Name of the file used by `PersistentScheduler` to store the last run times
  1120. of periodic tasks. Can be a relative or absolute path, but be aware that the
  1121. suffix `.db` may be appended to the file name (depending on Python version).
  1122. Can also be set via the :option:`--schedule` argument to
  1123. :mod:`~celery.bin.beat`.
  1124. .. setting:: CELERYBEAT_MAX_LOOP_INTERVAL
  1125. CELERYBEAT_MAX_LOOP_INTERVAL
  1126. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1127. The maximum number of seconds :mod:`~celery.bin.beat` can sleep
  1128. between checking the schedule.
  1129. The default for this value is scheduler specific.
  1130. For the default celery beat scheduler the value is 300 (5 minutes),
  1131. but for e.g. the django-celery database scheduler it is 5 seconds
  1132. because the schedule may be changed externally, and so it must take
  1133. changes to the schedule into account.
  1134. Also when running celery beat embedded (:option:`-B`) on Jython as a thread
  1135. the max interval is overridden and set to 1 so that it's possible
  1136. to shut down in a timely manner.
  1137. .. _conf-celerymon:
  1138. Monitor Server: celerymon
  1139. -------------------------
  1140. .. setting:: CELERYMON_LOG_FORMAT
  1141. CELERYMON_LOG_FORMAT
  1142. ~~~~~~~~~~~~~~~~~~~~
  1143. The format to use for log messages.
  1144. Default is `[%(asctime)s: %(levelname)s/%(processName)s] %(message)s`
  1145. See the Python :mod:`logging` module for more information about log
  1146. formats.