configuration.rst 48 KB

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