configuration.rst 45 KB

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