configuration.rst 42 KB

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