configuration.rst 41 KB

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