configuration.rst 45 KB

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