configuration.rst 42 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695
  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 the Kombu documentation for more information about broker URLs.
  515. .. setting:: BROKER_HEARTBEAT
  516. BROKER_HEARTBEAT
  517. ~~~~~~~~~~~~~~~~
  518. :transports supported: ``pyamqp``
  519. It's not always possible to detect connection loss in a timely
  520. manner using TCP/IP alone, so AMQP defines something called heartbeats
  521. that's is used both by the client and the broker to detect if
  522. a connection was closed.
  523. Hartbeats are disabled by default.
  524. If the heartbeat value is 10 seconds, then
  525. the heartbeat will be monitored at the interval specified
  526. by the :setting:`BROKER_HEARTBEAT_CHECKRATE` setting, which by default is
  527. double the rate of the heartbeat value
  528. (so for the default 10 seconds, the heartbeat is checked every 5 seconds).
  529. .. setting:: BROKER_HEARTBEAT_CHECKRATE
  530. BROKER_HEARTBEAT_CHECKRATE
  531. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  532. :transports supported: ``pyamqp``
  533. At intervals the worker will monitor that the broker has not missed
  534. too many heartbeats. The rate at which this is checked is calculated
  535. by dividing the :setting:`BROKER_HEARTBEAT` value with this value,
  536. so if the heartbeat is 10.0 and the rate is the default 2.0, the check
  537. will be performed every 5 seconds (twice the heartbeat sending rate).
  538. .. setting:: BROKER_USE_SSL
  539. BROKER_USE_SSL
  540. ~~~~~~~~~~~~~~
  541. Use SSL to connect to the broker. Off by default. This may not be supported
  542. by all transports.
  543. .. setting:: BROKER_POOL_LIMIT
  544. BROKER_POOL_LIMIT
  545. ~~~~~~~~~~~~~~~~~
  546. .. versionadded:: 2.3
  547. The maximum number of connections that can be open in the connection pool.
  548. The pool is enabled by default since version 2.5, with a default limit of ten
  549. connections. This number can be tweaked depending on the number of
  550. threads/greenthreads (eventlet/gevent) using a connection. For example
  551. running eventlet with 1000 greenlets that use a connection to the broker,
  552. contention can arise and you should consider increasing the limit.
  553. If set to :const:`None` or 0 the connection pool will be disabled and
  554. connections will be established and closed for every use.
  555. Default (since 2.5) is to use a pool of 10 connections.
  556. .. setting:: BROKER_CONNECTION_TIMEOUT
  557. BROKER_CONNECTION_TIMEOUT
  558. ~~~~~~~~~~~~~~~~~~~~~~~~~
  559. The default timeout in seconds before we give up establishing a connection
  560. to the AMQP server. Default is 4 seconds.
  561. .. setting:: BROKER_CONNECTION_RETRY
  562. BROKER_CONNECTION_RETRY
  563. ~~~~~~~~~~~~~~~~~~~~~~~
  564. Automatically try to re-establish the connection to the AMQP broker if lost.
  565. The time between retries is increased for each retry, and is
  566. not exhausted before :setting:`BROKER_CONNECTION_MAX_RETRIES` is
  567. exceeded.
  568. This behavior is on by default.
  569. .. setting:: BROKER_CONNECTION_MAX_RETRIES
  570. BROKER_CONNECTION_MAX_RETRIES
  571. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  572. Maximum number of retries before we give up re-establishing a connection
  573. to the AMQP broker.
  574. If this is set to :const:`0` or :const:`None`, we will retry forever.
  575. Default is 100 retries.
  576. .. setting:: BROKER_TRANSPORT_OPTIONS
  577. BROKER_TRANSPORT_OPTIONS
  578. ~~~~~~~~~~~~~~~~~~~~~~~~
  579. .. versionadded:: 2.2
  580. A dict of additional options passed to the underlying transport.
  581. See your transport user manual for supported options (if any).
  582. Example setting the visibility timeout (supported by Redis and SQS
  583. transports):
  584. .. code-block:: python
  585. BROKER_TRANSPORT_OPTIONS = {'visibility_timeout': 18000} # 5 hours
  586. .. _conf-task-execution:
  587. Task execution settings
  588. -----------------------
  589. .. setting:: CELERY_ALWAYS_EAGER
  590. CELERY_ALWAYS_EAGER
  591. ~~~~~~~~~~~~~~~~~~~
  592. If this is :const:`True`, all tasks will be executed locally by blocking until
  593. the task returns. ``apply_async()`` and ``Task.delay()`` will return
  594. an :class:`~celery.result.EagerResult` instance, which emulates the API
  595. and behavior of :class:`~celery.result.AsyncResult`, except the result
  596. is already evaluated.
  597. That is, tasks will be executed locally instead of being sent to
  598. the queue.
  599. .. setting:: CELERY_EAGER_PROPAGATES_EXCEPTIONS
  600. CELERY_EAGER_PROPAGATES_EXCEPTIONS
  601. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  602. If this is :const:`True`, eagerly executed tasks (applied by `task.apply()`,
  603. or when the :setting:`CELERY_ALWAYS_EAGER` setting is enabled), will
  604. propagate exceptions.
  605. It's the same as always running ``apply()`` with ``throw=True``.
  606. .. setting:: CELERY_IGNORE_RESULT
  607. CELERY_IGNORE_RESULT
  608. ~~~~~~~~~~~~~~~~~~~~
  609. Whether to store the task return values or not (tombstones).
  610. If you still want to store errors, just not successful return values,
  611. you can set :setting:`CELERY_STORE_ERRORS_EVEN_IF_IGNORED`.
  612. .. setting:: CELERY_MESSAGE_COMPRESSION
  613. CELERY_MESSAGE_COMPRESSION
  614. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  615. Default compression used for task messages.
  616. Can be ``"gzip"``, ``"bzip2"`` (if available), or any custom
  617. compression schemes registered in the Kombu compression registry.
  618. The default is to send uncompressed messages.
  619. .. setting:: CELERY_TASK_RESULT_EXPIRES
  620. CELERY_TASK_RESULT_EXPIRES
  621. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  622. Time (in seconds, or a :class:`~datetime.timedelta` object) for when after
  623. stored task tombstones will be deleted.
  624. A built-in periodic task will delete the results after this time
  625. (:class:`celery.task.backend_cleanup`).
  626. Default is to expire after 1 day.
  627. .. note::
  628. For the moment this only works with the amqp, database, cache, redis and MongoDB
  629. backends.
  630. When using the database or MongoDB backends, `celerybeat` must be
  631. running for the results to be expired.
  632. .. setting:: CELERY_MAX_CACHED_RESULTS
  633. CELERY_MAX_CACHED_RESULTS
  634. ~~~~~~~~~~~~~~~~~~~~~~~~~
  635. Result backends caches ready results used by the client.
  636. This is the total number of results to cache before older results are evicted.
  637. The default is 5000.
  638. .. setting:: CELERY_CHORD_PROPAGATES
  639. CELERY_CHORD_PROPAGATES
  640. ~~~~~~~~~~~~~~~~~~~~~~~
  641. .. versionadded:: 3.0.14
  642. This setting defines what happens when a task part of a chord raises an
  643. exception:
  644. - If propagate is True the chord callback will change state to FAILURE
  645. with the exception value set to a :exc:`~celery.exceptions.ChordError`
  646. instance containing information about the error and the task that failed.
  647. This is the default behavior in Celery 3.1+
  648. - If propagate is False the exception value will instead be forwarded
  649. to the chord callback.
  650. This was the default behavior before version 3.1.
  651. .. setting:: CELERY_TRACK_STARTED
  652. CELERY_TRACK_STARTED
  653. ~~~~~~~~~~~~~~~~~~~~
  654. If :const:`True` the task will report its status as "started" when the
  655. task is executed by a worker. The default value is :const:`False` as
  656. the normal behaviour is to not report that level of granularity. Tasks
  657. are either pending, finished, or waiting to be retried. Having a "started"
  658. state can be useful for when there are long running tasks and there is a
  659. need to report which task is currently running.
  660. .. setting:: CELERY_TASK_SERIALIZER
  661. CELERY_TASK_SERIALIZER
  662. ~~~~~~~~~~~~~~~~~~~~~~
  663. A string identifying the default serialization method to use. Can be
  664. `pickle` (default), `json`, `yaml`, `msgpack` or any custom serialization
  665. methods that have been registered with :mod:`kombu.serialization.registry`.
  666. .. seealso::
  667. :ref:`calling-serializers`.
  668. .. setting:: CELERY_TASK_PUBLISH_RETRY
  669. CELERY_TASK_PUBLISH_RETRY
  670. ~~~~~~~~~~~~~~~~~~~~~~~~~
  671. .. versionadded:: 2.2
  672. Decides if publishing task messages will be retried in the case
  673. of connection loss or other connection errors.
  674. See also :setting:`CELERY_TASK_PUBLISH_RETRY_POLICY`.
  675. Enabled by default.
  676. .. setting:: CELERY_TASK_PUBLISH_RETRY_POLICY
  677. CELERY_TASK_PUBLISH_RETRY_POLICY
  678. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  679. .. versionadded:: 2.2
  680. Defines the default policy when retrying publishing a task message in
  681. the case of connection loss or other connection errors.
  682. See :ref:`calling-retry` for more information.
  683. .. setting:: CELERY_DEFAULT_RATE_LIMIT
  684. CELERY_DEFAULT_RATE_LIMIT
  685. ~~~~~~~~~~~~~~~~~~~~~~~~~
  686. The global default rate limit for tasks.
  687. This value is used for tasks that does not have a custom rate limit
  688. The default is no rate limit.
  689. .. setting:: CELERY_DISABLE_RATE_LIMITS
  690. CELERY_DISABLE_RATE_LIMITS
  691. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  692. Disable all rate limits, even if tasks has explicit rate limits set.
  693. .. setting:: CELERY_ACKS_LATE
  694. CELERY_ACKS_LATE
  695. ~~~~~~~~~~~~~~~~
  696. Late ack means the task messages will be acknowledged **after** the task
  697. has been executed, not *just before*, which is the default behavior.
  698. .. seealso::
  699. FAQ: :ref:`faq-acks_late-vs-retry`.
  700. .. _conf-celeryd:
  701. Worker: celeryd
  702. ---------------
  703. .. setting:: CELERY_IMPORTS
  704. CELERY_IMPORTS
  705. ~~~~~~~~~~~~~~
  706. A sequence of modules to import when the worker starts.
  707. This is used to specify the task modules to import, but also
  708. to import signal handlers and additional remote control commands, etc.
  709. The modules will be imported in the original order.
  710. .. setting:: CELERY_INCLUDE
  711. CELERY_INCLUDE
  712. ~~~~~~~~~~~~~~
  713. Exact same semantics as :setting:`CELERY_IMPORTS`, but can be used as a means
  714. to have different import categories.
  715. The modules in this setting are imported after the modules in
  716. :setting:`CELERY_IMPORTS`.
  717. .. setting:: CELERYD_FORCE_EXECV
  718. CELERYD_FORCE_EXECV
  719. ~~~~~~~~~~~~~~~~~~~
  720. On Unix the processes pool will fork, so that child processes
  721. start with the same memory as the parent process.
  722. This can cause problems as there is a known deadlock condition
  723. with pthread locking primitives when `fork()` is combined with threads.
  724. You should enable this setting if you are experiencing hangs (deadlocks),
  725. especially in combination with time limits or having a max tasks per child limit.
  726. This option will be enabled by default in a later version.
  727. This is not a problem on Windows, as it does not have `fork()`.
  728. .. setting:: CELERYD_WORKER_LOST_WAIT
  729. CELERYD_WORKER_LOST_WAIT
  730. ~~~~~~~~~~~~~~~~~~~~~~~~
  731. In some cases a worker may be killed without proper cleanup,
  732. and the worker may have published a result before terminating.
  733. This value specifies how long we wait for any missing results before
  734. raising a :exc:`@WorkerLostError` exception.
  735. Default is 10.0
  736. .. setting:: CELERYD_MAX_TASKS_PER_CHILD
  737. CELERYD_MAX_TASKS_PER_CHILD
  738. ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  739. Maximum number of tasks a pool worker process can execute before
  740. it's replaced with a new one. Default is no limit.
  741. .. setting:: CELERYD_TASK_TIME_LIMIT
  742. CELERYD_TASK_TIME_LIMIT
  743. ~~~~~~~~~~~~~~~~~~~~~~~
  744. Task hard time limit in seconds. The worker processing the task will
  745. be killed and replaced with a new one when this is exceeded.
  746. .. setting:: CELERYD_TASK_SOFT_TIME_LIMIT
  747. CELERYD_TASK_SOFT_TIME_LIMIT
  748. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  749. Task soft time limit in seconds.
  750. The :exc:`~@SoftTimeLimitExceeded` exception will be
  751. raised when this is exceeded. The task can catch this to
  752. e.g. clean up before the hard time limit comes.
  753. Example:
  754. .. code-block:: python
  755. from celery.exceptions import SoftTimeLimitExceeded
  756. @celery.task
  757. def mytask():
  758. try:
  759. return do_work()
  760. except SoftTimeLimitExceeded:
  761. cleanup_in_a_hurry()
  762. .. setting:: CELERY_STORE_ERRORS_EVEN_IF_IGNORED
  763. CELERY_STORE_ERRORS_EVEN_IF_IGNORED
  764. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  765. If set, the worker stores all task errors in the result store even if
  766. :attr:`Task.ignore_result <celery.task.base.Task.ignore_result>` is on.
  767. .. setting:: CELERYD_STATE_DB
  768. CELERYD_STATE_DB
  769. ~~~~~~~~~~~~~~~~
  770. Name of the file used to stores persistent worker state (like revoked tasks).
  771. Can be a relative or absolute path, but be aware that the suffix `.db`
  772. may be appended to the file name (depending on Python version).
  773. Can also be set via the :option:`--statedb` argument to
  774. :mod:`~celery.bin.celeryd`.
  775. Not enabled by default.
  776. .. setting:: CELERYD_TIMER_PRECISION
  777. CELERYD_TIMER_PRECISION
  778. ~~~~~~~~~~~~~~~~~~~~~~~
  779. Set the maximum time in seconds that the ETA scheduler can sleep between
  780. rechecking the schedule. Default is 1 second.
  781. Setting this value to 1 second means the schedulers precision will
  782. be 1 second. If you need near millisecond precision you can set this to 0.1.
  783. .. _conf-error-mails:
  784. Error E-Mails
  785. -------------
  786. .. setting:: CELERY_SEND_TASK_ERROR_EMAILS
  787. CELERY_SEND_TASK_ERROR_EMAILS
  788. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  789. The default value for the `Task.send_error_emails` attribute, which if
  790. set to :const:`True` means errors occurring during task execution will be
  791. sent to :setting:`ADMINS` by email.
  792. Disabled by default.
  793. .. setting:: ADMINS
  794. ADMINS
  795. ~~~~~~
  796. List of `(name, email_address)` tuples for the administrators that should
  797. receive error emails.
  798. .. setting:: SERVER_EMAIL
  799. SERVER_EMAIL
  800. ~~~~~~~~~~~~
  801. The email address this worker sends emails from.
  802. Default is celery@localhost.
  803. .. setting:: EMAIL_HOST
  804. EMAIL_HOST
  805. ~~~~~~~~~~
  806. The mail server to use. Default is `"localhost"`.
  807. .. setting:: EMAIL_HOST_USER
  808. EMAIL_HOST_USER
  809. ~~~~~~~~~~~~~~~
  810. User name (if required) to log on to the mail server with.
  811. .. setting:: EMAIL_HOST_PASSWORD
  812. EMAIL_HOST_PASSWORD
  813. ~~~~~~~~~~~~~~~~~~~
  814. Password (if required) to log on to the mail server with.
  815. .. setting:: EMAIL_PORT
  816. EMAIL_PORT
  817. ~~~~~~~~~~
  818. The port the mail server is listening on. Default is `25`.
  819. .. setting:: EMAIL_USE_SSL
  820. EMAIL_USE_SSL
  821. ~~~~~~~~~~~~~
  822. Use SSL when connecting to the SMTP server. Disabled by default.
  823. .. setting:: EMAIL_USE_TLS
  824. EMAIL_USE_TLS
  825. ~~~~~~~~~~~~~
  826. Use TLS when connecting to the SMTP server. Disabled by default.
  827. .. setting:: EMAIL_TIMEOUT
  828. EMAIL_TIMEOUT
  829. ~~~~~~~~~~~~~
  830. Timeout in seconds for when we give up trying to connect
  831. to the SMTP server when sending emails.
  832. The default is 2 seconds.
  833. .. _conf-example-error-mail-config:
  834. Example E-Mail configuration
  835. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  836. This configuration enables the sending of error emails to
  837. george@vandelay.com and kramer@vandelay.com:
  838. .. code-block:: python
  839. # Enables error emails.
  840. CELERY_SEND_TASK_ERROR_EMAILS = True
  841. # Name and email addresses of recipients
  842. ADMINS = (
  843. ("George Costanza", "george@vandelay.com"),
  844. ("Cosmo Kramer", "kosmo@vandelay.com"),
  845. )
  846. # Email address used as sender (From field).
  847. SERVER_EMAIL = "no-reply@vandelay.com"
  848. # Mailserver configuration
  849. EMAIL_HOST = "mail.vandelay.com"
  850. EMAIL_PORT = 25
  851. # EMAIL_HOST_USER = "servers"
  852. # EMAIL_HOST_PASSWORD = "s3cr3t"
  853. .. _conf-events:
  854. Events
  855. ------
  856. .. setting:: CELERY_SEND_EVENTS
  857. CELERY_SEND_EVENTS
  858. ~~~~~~~~~~~~~~~~~~
  859. Send events so the worker can be monitored by tools like `celerymon`.
  860. .. setting:: CELERY_SEND_TASK_SENT_EVENT
  861. CELERY_SEND_TASK_SENT_EVENT
  862. ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  863. .. versionadded:: 2.2
  864. If enabled, a :event:`task-sent` event will be sent for every task so tasks can be
  865. tracked before they are consumed by a worker.
  866. Disabled by default.
  867. .. setting:: CELERY_EVENT_SERIALIZER
  868. CELERY_EVENT_SERIALIZER
  869. ~~~~~~~~~~~~~~~~~~~~~~~
  870. Message serialization format used when sending event messages.
  871. Default is `"json"`. See :ref:`calling-serializers`.
  872. .. _conf-broadcast:
  873. Broadcast Commands
  874. ------------------
  875. .. setting:: CELERY_BROADCAST_QUEUE
  876. CELERY_BROADCAST_QUEUE
  877. ~~~~~~~~~~~~~~~~~~~~~~
  878. Name prefix for the queue used when listening for broadcast messages.
  879. The workers host name will be appended to the prefix to create the final
  880. queue name.
  881. Default is `"celeryctl"`.
  882. .. setting:: CELERY_BROADCAST_EXCHANGE
  883. CELERY_BROADCAST_EXCHANGE
  884. ~~~~~~~~~~~~~~~~~~~~~~~~~
  885. Name of the exchange used for broadcast messages.
  886. Default is `"celeryctl"`.
  887. .. setting:: CELERY_BROADCAST_EXCHANGE_TYPE
  888. CELERY_BROADCAST_EXCHANGE_TYPE
  889. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  890. Exchange type used for broadcast messages. Default is `"fanout"`.
  891. .. _conf-logging:
  892. Logging
  893. -------
  894. .. setting:: CELERYD_HIJACK_ROOT_LOGGER
  895. CELERYD_HIJACK_ROOT_LOGGER
  896. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  897. .. versionadded:: 2.2
  898. By default any previously configured logging options will be reset,
  899. because the Celery programs "hijacks" the root logger.
  900. If you want to customize your own logging then you can disable
  901. this behavior.
  902. .. note::
  903. Logging can also be customized by connecting to the
  904. :signal:`celery.signals.setup_logging` signal.
  905. .. setting:: CELERYD_LOG_COLOR
  906. CELERYD_LOG_COLOR
  907. ~~~~~~~~~~~~~~~~~
  908. Enables/disables colors in logging output by the Celery apps.
  909. By default colors are enabled if
  910. 1) the app is logging to a real terminal, and not a file.
  911. 2) the app is not running on Windows.
  912. .. setting:: CELERYD_LOG_FORMAT
  913. CELERYD_LOG_FORMAT
  914. ~~~~~~~~~~~~~~~~~~
  915. The format to use for log messages.
  916. Default is `[%(asctime)s: %(levelname)s/%(processName)s] %(message)s`
  917. See the Python :mod:`logging` module for more information about log
  918. formats.
  919. .. setting:: CELERYD_TASK_LOG_FORMAT
  920. CELERYD_TASK_LOG_FORMAT
  921. ~~~~~~~~~~~~~~~~~~~~~~~
  922. The format to use for log messages logged in tasks. Can be overridden using
  923. the :option:`--loglevel` option to :mod:`~celery.bin.celeryd`.
  924. Default is::
  925. [%(asctime)s: %(levelname)s/%(processName)s]
  926. [%(task_name)s(%(task_id)s)] %(message)s
  927. See the Python :mod:`logging` module for more information about log
  928. formats.
  929. .. setting:: CELERY_REDIRECT_STDOUTS
  930. CELERY_REDIRECT_STDOUTS
  931. ~~~~~~~~~~~~~~~~~~~~~~~
  932. If enabled `stdout` and `stderr` will be redirected
  933. to the current logger.
  934. Enabled by default.
  935. Used by :program:`celeryd` and :program:`celerybeat`.
  936. .. setting:: CELERY_REDIRECT_STDOUTS_LEVEL
  937. CELERY_REDIRECT_STDOUTS_LEVEL
  938. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  939. The log level output to `stdout` and `stderr` is logged as.
  940. Can be one of :const:`DEBUG`, :const:`INFO`, :const:`WARNING`,
  941. :const:`ERROR` or :const:`CRITICAL`.
  942. Default is :const:`WARNING`.
  943. .. _conf-security:
  944. Security
  945. --------
  946. .. setting:: CELERY_SECURITY_KEY
  947. CELERY_SECURITY_KEY
  948. ~~~~~~~~~~~~~~~~~~~
  949. .. versionadded:: 2.5
  950. The relative or absolute path to a file containing the private key
  951. used to sign messages when :ref:`message-signing` is used.
  952. .. setting:: CELERY_SECURITY_CERTIFICATE
  953. CELERY_SECURITY_CERTIFICATE
  954. ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  955. .. versionadded:: 2.5
  956. The relative or absolute path to an X.509 certificate file
  957. used to sign messages when :ref:`message-signing` is used.
  958. .. setting:: CELERY_SECURITY_CERT_STORE
  959. CELERY_SECURITY_CERT_STORE
  960. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  961. .. versionadded:: 2.5
  962. The directory containing X.509 certificates used for
  963. :ref:`message-signing`. Can be a glob with wildcards,
  964. (for example :file:`/etc/certs/*.pem`).
  965. .. _conf-custom-components:
  966. Custom Component Classes (advanced)
  967. -----------------------------------
  968. .. setting:: CELERYD_BOOT_STEPS
  969. CELERYD_BOOT_STEPS
  970. ~~~~~~~~~~~~~~~~~~
  971. This setting enables you to add additional components to the worker process.
  972. It should be a list of module names with :class:`celery.abstract.Component`
  973. classes, that augments functionality in the worker.
  974. .. setting:: CELERYD_POOL
  975. CELERYD_POOL
  976. ~~~~~~~~~~~~
  977. Name of the pool class used by the worker.
  978. You can use a custom pool class name, or select one of
  979. the built-in aliases: ``processes``, ``eventlet``, ``gevent``.
  980. Default is ``processes``.
  981. .. setting:: CELERYD_POOL_RESTARTS
  982. CELERYD_POOL_RESTARTS
  983. ~~~~~~~~~~~~~~~~~~~~~
  984. If enabled the worker pool can be restarted using the
  985. :control:`pool_restart` remote control command.
  986. Disabled by default.
  987. .. setting:: CELERYD_AUTOSCALER
  988. CELERYD_AUTOSCALER
  989. ~~~~~~~~~~~~~~~~~~
  990. .. versionadded:: 2.2
  991. Name of the autoscaler class to use.
  992. Default is ``"celery.worker.autoscale.Autoscaler"``.
  993. .. setting:: CELERYD_AUTORELOADER
  994. CELERYD_AUTORELOADER
  995. ~~~~~~~~~~~~~~~~~~~~
  996. Name of the autoreloader class used by the worker to reload
  997. Python modules and files that have changed.
  998. Default is: ``"celery.worker.autoreload.Autoreloader"``.
  999. .. setting:: CELERYD_CONSUMER
  1000. CELERYD_CONSUMER
  1001. ~~~~~~~~~~~~~~~~
  1002. Name of the consumer class used by the worker.
  1003. Default is :class:`celery.worker.consumer.Consumer`
  1004. .. setting:: CELERYD_MEDIATOR
  1005. CELERYD_MEDIATOR
  1006. ~~~~~~~~~~~~~~~~
  1007. Name of the mediator class used by the worker.
  1008. Default is :class:`celery.worker.controllers.Mediator`.
  1009. .. setting:: CELERYD_TIMER
  1010. CELERYD_TIMER
  1011. ~~~~~~~~~~~~~~~~~~~~~
  1012. Name of the ETA scheduler class used by the worker.
  1013. Default is :class:`celery.utils.timer2.Timer`, or one overrided
  1014. by the pool implementation.
  1015. .. _conf-celerybeat:
  1016. Periodic Task Server: celerybeat
  1017. --------------------------------
  1018. .. setting:: CELERYBEAT_SCHEDULE
  1019. CELERYBEAT_SCHEDULE
  1020. ~~~~~~~~~~~~~~~~~~~
  1021. The periodic task schedule used by :mod:`~celery.bin.celerybeat`.
  1022. See :ref:`beat-entries`.
  1023. .. setting:: CELERYBEAT_SCHEDULER
  1024. CELERYBEAT_SCHEDULER
  1025. ~~~~~~~~~~~~~~~~~~~~
  1026. The default scheduler class. Default is
  1027. `"celery.beat.PersistentScheduler"`.
  1028. Can also be set via the :option:`-S` argument to
  1029. :mod:`~celery.bin.celerybeat`.
  1030. .. setting:: CELERYBEAT_SCHEDULE_FILENAME
  1031. CELERYBEAT_SCHEDULE_FILENAME
  1032. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1033. Name of the file used by `PersistentScheduler` to store the last run times
  1034. of periodic tasks. Can be a relative or absolute path, but be aware that the
  1035. suffix `.db` may be appended to the file name (depending on Python version).
  1036. Can also be set via the :option:`--schedule` argument to
  1037. :mod:`~celery.bin.celerybeat`.
  1038. .. setting:: CELERYBEAT_MAX_LOOP_INTERVAL
  1039. CELERYBEAT_MAX_LOOP_INTERVAL
  1040. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1041. The maximum number of seconds :mod:`~celery.bin.celerybeat` can sleep
  1042. between checking the schedule.
  1043. The default for this value is scheduler specific.
  1044. For the default celerybeat scheduler the value is 300 (5 minutes),
  1045. but for e.g. the django-celery database scheduler it is 5 seconds
  1046. because the schedule may be changed externally, and so it must take
  1047. changes to the schedule into account.
  1048. Also when running celerybeat embedded (:option:`-B`) on Jython as a thread
  1049. the max interval is overridden and set to 1 so that it's possible
  1050. to shut down in a timely manner.
  1051. .. _conf-celerymon:
  1052. Monitor Server: celerymon
  1053. -------------------------
  1054. .. setting:: CELERYMON_LOG_FORMAT
  1055. CELERYMON_LOG_FORMAT
  1056. ~~~~~~~~~~~~~~~~~~~~
  1057. The format to use for log messages.
  1058. Default is `[%(asctime)s: %(levelname)s/%(processName)s] %(message)s`
  1059. See the Python :mod:`logging` module for more information about log
  1060. formats.