configuration.rst 42 KB

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