configuration.rst 42 KB

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