configuration.rst 59 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277
  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's 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 the Celery worker starts.
  20. imports = ('myapp.tasks',)
  21. ## Using the database to store task state and results.
  22. result_backend = 'db+sqlite:///results.db'
  23. task_annotations = {'tasks.add': {'rate_limit': '10/s'}}
  24. .. _conf-old-settings-map:
  25. New lowercase settings
  26. ======================
  27. Version 4.0 introduced new lower case settings and setting organization.
  28. The major difference between previous versions, apart from the lower case
  29. names, are the renaming of some prefixes, like ``celerybeat_`` to ``beat_``,
  30. ``celeryd_`` to ``worker_``, and most of the top level ``celery_`` settings
  31. have been moved into a new ``task_`` prefix.
  32. Celery will still be able to read old configuration files, so there's no
  33. rush in moving to the new settings format.
  34. ===================================== ==============================================
  35. **Setting name** **Replace with**
  36. ===================================== ==============================================
  37. ``CELERY_ACCEPT_CONTENT`` :setting:`accept_content`
  38. ``CELERY_ENABLE_UTC`` :setting:`enable_utc`
  39. ``CELERY_IMPORTS`` :setting:`imports`
  40. ``CELERY_INCLUDE`` :setting:`include`
  41. ``CELERY_TIMEZONE`` :setting:`timezone`
  42. ``CELERYBEAT_MAX_LOOP_INTERVAL`` :setting:`beat_max_loop_interval`
  43. ``CELERYBEAT_SCHEDULE`` :setting:`beat_schedule`
  44. ``CELERYBEAT_SCHEDULER`` :setting:`beat_scheduler`
  45. ``CELERYBEAT_SCHEDULE_FILENAME`` :setting:`beat_schedule_filename`
  46. ``CELERYBEAT_SYNC_EVERY`` :setting:`beat_sync_every`
  47. ``BROKER_URL`` :setting:`broker_url`
  48. ``BROKER_TRANSPORT`` :setting:`broker_transport`
  49. ``BROKER_TRANSPORT_OPTIONS`` :setting:`broker_transport_options`
  50. ``BROKER_CONNECTION_TIMEOUT`` :setting:`broker_connection_timeout`
  51. ``BROKER_CONNECTION_RETRY`` :setting:`broker_connection_retry`
  52. ``BROKER_CONNECTION_MAX_RETRIES`` :setting:`broker_connection_max_retries`
  53. ``BROKER_FAILOVER_STRATEGY`` :setting:`broker_failover_strategy`
  54. ``BROKER_HEARTBEAT`` :setting:`broker_heartbeat`
  55. ``BROKER_LOGIN_METHOD`` :setting:`broker_login_method`
  56. ``BROKER_POOL_LIMIT`` :setting:`broker_pool_limit`
  57. ``BROKER_USE_SSL`` :setting:`broker_use_ssl`
  58. ``CELERY_CACHE_BACKEND`` :setting:`cache_backend`
  59. ``CELERY_CACHE_BACKEND_OPTIONS`` :setting:`cache_backend_options`
  60. ``CASSANDRA_COLUMN_FAMILY`` :setting:`cassandra_table`
  61. ``CASSANDRA_ENTRY_TTL`` :setting:`cassandra_entry_ttl`
  62. ``CASSANDRA_KEYSPACE`` :setting:`cassandra_keyspace`
  63. ``CASSANDRA_PORT`` :setting:`cassandra_port`
  64. ``CASSANDRA_READ_CONSISTENCY`` :setting:`cassandra_read_consistency`
  65. ``CASSANDRA_SERVERS`` :setting:`cassandra_servers`
  66. ``CASSANDRA_WRITE_CONSISTENCY`` :setting:`cassandra_write_consistency`
  67. ``CELERY_COUCHBASE_BACKEND_SETTINGS`` :setting:`couchbase_backend_settings`
  68. ``CELERY_MONGODB_BACKEND_SETTINGS`` :setting:`mongodb_backend_settings`
  69. ``CELERY_EVENT_QUEUE_EXPIRES`` :setting:`event_queue_expires`
  70. ``CELERY_EVENT_QUEUE_TTL`` :setting:`event_queue_ttl`
  71. ``CELERY_EVENT_QUEUE_PREFIX`` :setting:`event_queue_prefix`
  72. ``CELERY_EVENT_SERIALIZER`` :setting:`event_serializer`
  73. ``CELERY_REDIS_DB`` :setting:`redis_db`
  74. ``CELERY_REDIS_HOST`` :setting:`redis_host`
  75. ``CELERY_REDIS_MAX_CONNECTIONS`` :setting:`redis_max_connections`
  76. ``CELERY_REDIS_PASSWORD`` :setting:`redis_password`
  77. ``CELERY_REDIS_PORT`` :setting:`redis_port`
  78. ``CELERY_RESULT_BACKEND`` :setting:`result_backend`
  79. ``CELERY_MAX_CACHED_RESULTS`` :setting:`result_cache_max`
  80. ``CELERY_MESSAGE_COMPRESSION`` :setting:`result_compression`
  81. ``CELERY_RESULT_EXCHANGE`` :setting:`result_exchange`
  82. ``CELERY_RESULT_EXCHANGE_TYPE`` :setting:`result_exchange_type`
  83. ``CELERY_TASK_RESULT_EXPIRES`` :setting:`result_expires`
  84. ``CELERY_RESULT_PERSISTENT`` :setting:`result_persistent`
  85. ``CELERY_RESULT_SERIALIZER`` :setting:`result_serializer`
  86. ``CELERY_RESULT_DBURI`` :setting:`sqlalchemy_dburi`
  87. ``CELERY_RESULT_ENGINE_OPTIONS`` :setting:`sqlalchemy_engine_options`
  88. ``-*-_DB_SHORT_LIVED_SESSIONS`` :setting:`sqlalchemy_short_lived_sessions`
  89. ``CELERY_RESULT_DB_TABLE_NAMES`` :setting:`sqlalchemy_db_names`
  90. ``CELERY_SECURITY_CERTIFICATE`` :setting:`security_certificate`
  91. ``CELERY_SECURITY_CERT_STORE`` :setting:`security_cert_store`
  92. ``CELERY_SECURITY_KEY`` :setting:`security_key`
  93. ``CELERY_ACKS_LATE`` :setting:`task_acks_late`
  94. ``CELERY_ALWAYS_EAGER`` :setting:`task_always_eager`
  95. ``CELERY_ANNOTATIONS`` :setting:`task_annotations`
  96. ``CELERY_MESSAGE_COMPRESSION`` :setting:`task_compression`
  97. ``CELERY_CREATE_MISSING_QUEUES`` :setting:`task_create_missing_queues`
  98. ``CELERY_DEFAULT_DELIVERY_MODE`` :setting:`task_default_delivery_mode`
  99. ``CELERY_DEFAULT_EXCHANGE`` :setting:`task_default_exchange`
  100. ``CELERY_DEFAULT_EXCHANGE_TYPE`` :setting:`task_default_exchange_type`
  101. ``CELERY_DEFAULT_QUEUE`` :setting:`task_default_queue`
  102. ``CELERY_DEFAULT_RATE_LIMIT`` :setting:`task_default_rate_limit`
  103. ``CELERY_DEFAULT_ROUTING_KEY`` :setting:`task_default_routing_key`
  104. ``-'-_EAGER_PROPAGATES_EXCEPTIONS`` :setting:`task_eager_propagates`
  105. ``CELERY_IGNORE_RESULT`` :setting:`task_ignore_result`
  106. ``CELERY_TASK_PUBLISH_RETRY`` :setting:`task_publish_retry`
  107. ``CELERY_TASK_PUBLISH_RETRY_POLICY`` :setting:`task_publish_retry_policy`
  108. ``CELERY_QUEUES`` :setting:`task_queues`
  109. ``CELERY_ROUTES`` :setting:`task_routes`
  110. ``CELERY_SEND_TASK_SENT_EVENT`` :setting:`task_send_sent_event`
  111. ``CELERY_TASK_SERIALIZER`` :setting:`task_serializer`
  112. ``CELERYD_TASK_SOFT_TIME_LIMIT`` :setting:`task_soft_time_limit`
  113. ``CELERYD_TASK_TIME_LIMIT`` :setting:`task_time_limit`
  114. ``CELERY_TRACK_STARTED`` :setting:`task_track_started`
  115. ``CELERYD_AGENT`` :setting:`worker_agent`
  116. ``CELERYD_CONCURRENCY`` :setting:`worker_concurrency`
  117. ``CELERYD_CONSUMER`` :setting:`worker_consumer`
  118. ``CELERY_WORKER_DIRECT`` :setting:`worker_direct`
  119. ``CELERY_DISABLE_RATE_LIMITS`` :setting:`worker_disable_rate_limits`
  120. ``CELERY_ENABLE_REMOTE_CONTROL`` :setting:`worker_enable_remote_control`
  121. ``CELERYD_HIJACK_ROOT_LOGGER`` :setting:`worker_hijack_root_logger`
  122. ``CELERYD_LOG_COLOR`` :setting:`worker_log_color`
  123. ``CELERYD_LOG_FORMAT`` :setting:`worker_log_format`
  124. ``CELERYD_WORKER_LOST_WAIT`` :setting:`worker_lost_wait`
  125. ``CELERYD_MAX_TASKS_PER_CHILD`` :setting:`worker_max_tasks_per_child`
  126. ``CELERYD_POOL`` :setting:`worker_pool`
  127. ``CELERYD_POOL_PUTLOCKS`` :setting:`worker_pool_putlocks`
  128. ``CELERYD_POOL_RESTARTS`` :setting:`worker_pool_restarts`
  129. ``CELERYD_PREFETCH_MULTIPLIER`` :setting:`worker_prefetch_multiplier`
  130. ``CELERYD_REDIRECT_STDOUTS`` :setting:`worker_redirect_stdouts`
  131. ``CELERYD_REDIRECT_STDOUTS_LEVEL`` :setting:`worker_redirect_stdouts_level`
  132. ``CELERYD_SEND_EVENTS`` :setting:`worker_send_task_events`
  133. ``CELERYD_STATE_DB`` :setting:`worker_state_db`
  134. ``CELERYD_TASK_LOG_FORMAT`` :setting:`worker_task_log_format`
  135. ``CELERYD_TIMER`` :setting:`worker_timer`
  136. ``CELERYD_TIMER_PRECISION`` :setting:`worker_timer_precision`
  137. ===================================== ==============================================
  138. Configuration Directives
  139. ========================
  140. .. _conf-datetime:
  141. General settings
  142. ----------------
  143. .. setting:: accept_content
  144. ``accept_content``
  145. ~~~~~~~~~~~~~~~~~~
  146. Default: ``{'json'}`` (set, list, or tuple).
  147. A white-list of content-types/serializers to allow.
  148. If a message is received that's not in this list then
  149. the message will be discarded with an error.
  150. By default any content type is enabled (including pickle and yaml)
  151. so make sure untrusted parties don't have access to your broker.
  152. See :ref:`guide-security` for more.
  153. Example::
  154. # using serializer name
  155. accept_content = ['json']
  156. # or the actual content-type (MIME)
  157. accept_content = ['application/json']
  158. Time and date settings
  159. ----------------------
  160. .. setting:: enable_utc
  161. ``enable_utc``
  162. ~~~~~~~~~~~~~~
  163. .. versionadded:: 2.5
  164. Default: Enabled by default since version 3.0.
  165. If enabled dates and times in messages will be converted to use
  166. the UTC timezone.
  167. Note that workers running Celery versions below 2.5 will assume a local
  168. timezone for all messages, so only enable if all workers have been
  169. upgraded.
  170. .. setting:: timezone
  171. ``timezone``
  172. ~~~~~~~~~~~~
  173. .. versionadded:: 2.5
  174. Default: ``"UTC"``.
  175. Configure Celery to use a custom time zone.
  176. The timezone value can be any time zone supported by the :pypi:`pytz`
  177. library.
  178. If not set the UTC timezone is used. For backwards compatibility
  179. there's also a :setting:`enable_utc` setting, and this is set
  180. to false the system local timezone is used instead.
  181. .. _conf-tasks:
  182. Task settings
  183. -------------
  184. .. setting:: task_annotations
  185. ``task_annotations``
  186. ~~~~~~~~~~~~~~~~~~~~
  187. .. versionadded:: 2.5
  188. Default: :const:`None`.
  189. This setting can be used to rewrite any task attribute from the
  190. configuration. The setting can be a dict, or a list of annotation
  191. objects that filter for tasks and return a map of attributes
  192. to change.
  193. This will change the ``rate_limit`` attribute for the ``tasks.add``
  194. task:
  195. .. code-block:: python
  196. task_annotations = {'tasks.add': {'rate_limit': '10/s'}}
  197. or change the same for all tasks:
  198. .. code-block:: python
  199. task_annotations = {'*': {'rate_limit': '10/s'}}
  200. You can change methods too, for example the ``on_failure`` handler:
  201. .. code-block:: python
  202. def my_on_failure(self, exc, task_id, args, kwargs, einfo):
  203. print('Oh no! Task failed: {0!r}'.format(exc))
  204. task_annotations = {'*': {'on_failure': my_on_failure}}
  205. If you need more flexibility then you can use objects
  206. instead of a dict to choose which tasks to annotate:
  207. .. code-block:: python
  208. class MyAnnotate(object):
  209. def annotate(self, task):
  210. if task.name.startswith('tasks.'):
  211. return {'rate_limit': '10/s'}
  212. task_annotations = (MyAnnotate(), {other,})
  213. .. setting:: task_compression
  214. ``task_compression``
  215. ~~~~~~~~~~~~~~~~~~~~
  216. Default: :const:`None`
  217. Default compression used for task messages.
  218. Can be ``gzip``, ``bzip2`` (if available), or any custom
  219. compression schemes registered in the Kombu compression registry.
  220. The default is to send uncompressed messages.
  221. .. setting:: task_protocol
  222. ``task_protocol``
  223. ~~~~~~~~~~~~~~~~~
  224. .. versionadded: 4.0
  225. Default: 2 (since 4.0).
  226. Set the default task message protocol version used to send tasks.
  227. Supports protocols: 1 and 2.
  228. Protocol 2 is supported by 3.1.24 and 4.x+.
  229. .. setting:: task_serializer
  230. ``task_serializer``
  231. ~~~~~~~~~~~~~~~~~~~
  232. Default: ``"json"`` (since 4.0, earlier: pickle).
  233. A string identifying the default serialization method to use. Can be
  234. `json` (default), `pickle`, `yaml`, `msgpack`, or any custom serialization
  235. methods that have been registered with :mod:`kombu.serialization.registry`.
  236. .. seealso::
  237. :ref:`calling-serializers`.
  238. .. setting:: task_publish_retry
  239. ``task_publish_retry``
  240. ~~~~~~~~~~~~~~~~~~~~~~
  241. .. versionadded:: 2.2
  242. Default: Enabled.
  243. Decides if publishing task messages will be retried in the case
  244. of connection loss or other connection errors.
  245. See also :setting:`task_publish_retry_policy`.
  246. .. setting:: task_publish_retry_policy
  247. ``task_publish_retry_policy``
  248. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  249. .. versionadded:: 2.2
  250. Default: See :ref:`calling-retry`.
  251. Defines the default policy when retrying publishing a task message in
  252. the case of connection loss or other connection errors.
  253. .. _conf-task-execution:
  254. Task execution settings
  255. -----------------------
  256. .. setting:: task_always_eager
  257. ``task_always_eager``
  258. ~~~~~~~~~~~~~~~~~~~~~
  259. Default: Disabled.
  260. If this is :const:`True`, all tasks will be executed locally by blocking until
  261. the task returns. ``apply_async()`` and ``Task.delay()`` will return
  262. an :class:`~celery.result.EagerResult` instance, which emulates the API
  263. and behavior of :class:`~celery.result.AsyncResult`, except the result
  264. is already evaluated.
  265. That is, tasks will be executed locally instead of being sent to
  266. the queue.
  267. .. setting:: task_eager_propagates
  268. ``task_eager_propagates``
  269. ~~~~~~~~~~~~~~~~~~~~~~~~~
  270. Default: Disabled.
  271. If this is :const:`True`, eagerly executed tasks (applied by `task.apply()`,
  272. or when the :setting:`task_always_eager` setting is enabled), will
  273. propagate exceptions.
  274. It's the same as always running ``apply()`` with ``throw=True``.
  275. .. setting:: task_remote_tracebacks
  276. ``task_remote_tracebacks``
  277. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  278. Default: Disabled.
  279. If enabled task results will include the workers stack when re-raising
  280. task errors.
  281. This requires the :pypi:`tblib` library, which can be installed using
  282. :command:`pip`:
  283. .. code-block:: console
  284. $ pip install 'tblib>=1.3.0'
  285. .. setting:: task_ignore_result
  286. ``task_ignore_result``
  287. ~~~~~~~~~~~~~~~~~~~~~~
  288. Default: Disabled.
  289. Whether to store the task return values or not (tombstones).
  290. If you still want to store errors, just not successful return values,
  291. you can set :setting:`task_store_errors_even_if_ignored`.
  292. .. setting:: task_store_errors_even_if_ignored
  293. ``task_store_errors_even_if_ignored``
  294. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  295. Default: Disabled.
  296. If set, the worker stores all task errors in the result store even if
  297. :attr:`Task.ignore_result <celery.task.base.Task.ignore_result>` is on.
  298. .. setting:: task_track_started
  299. ``task_track_started``
  300. ~~~~~~~~~~~~~~~~~~~~~~
  301. Default: Disabled.
  302. If :const:`True` the task will report its status as 'started' when the
  303. task is executed by a worker. The default value is :const:`False` as
  304. the normal behavior is to not report that level of granularity. Tasks
  305. are either pending, finished, or waiting to be retried. Having a 'started'
  306. state can be useful for when there are long running tasks and there's a
  307. need to report which task is currently running.
  308. .. setting:: task_time_limit
  309. ``task_time_limit``
  310. ~~~~~~~~~~~~~~~~~~~
  311. Default: No time limit.
  312. Task hard time limit in seconds. The worker processing the task will
  313. be killed and replaced with a new one when this is exceeded.
  314. .. setting:: task_soft_time_limit
  315. ``task_soft_time_limit``
  316. ~~~~~~~~~~~~~~~~~~~~~~~~
  317. Default: No soft time limit.
  318. Task soft time limit in seconds.
  319. The :exc:`~@SoftTimeLimitExceeded` exception will be
  320. raised when this is exceeded. The task can catch this to
  321. e.g. clean up before the hard time limit comes.
  322. Example:
  323. .. code-block:: python
  324. from celery.exceptions import SoftTimeLimitExceeded
  325. @app.task
  326. def mytask():
  327. try:
  328. return do_work()
  329. except SoftTimeLimitExceeded:
  330. cleanup_in_a_hurry()
  331. .. setting:: task_acks_late
  332. ``task_acks_late``
  333. ~~~~~~~~~~~~~~~~~~
  334. Default: Disabled.
  335. Late ack means the task messages will be acknowledged **after** the task
  336. has been executed, not *just before*, which is the default behavior.
  337. .. seealso::
  338. FAQ: :ref:`faq-acks_late-vs-retry`.
  339. .. setting:: task_reject_on_worker_lost
  340. ``task_reject_on_worker_lost``
  341. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  342. Default: Disabled.
  343. Even if :setting:`task_acks_late` is enabled, the worker will
  344. acknowledge tasks when the worker process executing them abruptly
  345. exits or is signaled (e.g. :sig:`KILL`/:sig:`INT`, etc).
  346. Setting this to true allows the message to be re-queued instead,
  347. so that the task will execute again by the same worker, or another
  348. worker.
  349. .. warning::
  350. Enabling this can cause message loops; make sure you know
  351. what you're doing.
  352. .. setting:: task_default_rate_limit
  353. ``task_default_rate_limit``
  354. ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  355. Default: No rate limit.
  356. The global default rate limit for tasks.
  357. This value is used for tasks that doesn't have a custom rate limit
  358. .. seealso::
  359. The setting:`worker_disable_rate_limits` setting can
  360. disable all rate limits.
  361. .. _conf-result-backend:
  362. Task result backend settings
  363. ----------------------------
  364. .. setting:: result_backend
  365. ``result_backend``
  366. ~~~~~~~~~~~~~~~~~~
  367. Default: No result backend enabled by default.
  368. The backend used to store task results (tombstones).
  369. Can be one of the following:
  370. * ``rpc``
  371. Send results back as AMQP messages
  372. See :ref:`conf-rpc-result-backend`.
  373. * ``database``
  374. Use a relational database supported by `SQLAlchemy`_.
  375. See :ref:`conf-database-result-backend`.
  376. * ``redis``
  377. Use `Redis`_ to store the results.
  378. See :ref:`conf-redis-result-backend`.
  379. * ``cache``
  380. Use `Memcached`_ to store the results.
  381. See :ref:`conf-cache-result-backend`.
  382. * ``cassandra``
  383. Use `Cassandra`_ to store the results.
  384. See :ref:`conf-cassandra-result-backend`.
  385. * ``elasticsearch``
  386. Use `Elasticsearch`_ to store the results.
  387. See :ref:`conf-elasticsearch-result-backend`.
  388. * ``ironcache``
  389. Use `IronCache`_ to store the results.
  390. See :ref:`conf-ironcache-result-backend`.
  391. * ``couchbase``
  392. Use `Couchbase`_ to store the results.
  393. See :ref:`conf-couchbase-result-backend`.
  394. * ``couchdb``
  395. Use `CouchDB`_ to store the results.
  396. See :ref:`conf-couchdb-result-backend`.
  397. * ``filesystem``
  398. Use a shared directory to store the results.
  399. See :ref:`conf-filesystem-result-backend`.
  400. * ``consul``
  401. Use the `Consul`_ K/V store to store the results
  402. See :ref:`conf-consul-result-backend`.
  403. .. warning:
  404. While the AMQP result backend is very efficient, you must make sure
  405. you only receive the same result once. See :doc:`userguide/calling`).
  406. .. _`SQLAlchemy`: http://sqlalchemy.org
  407. .. _`Memcached`: http://memcached.org
  408. .. _`Redis`: http://redis.io
  409. .. _`Cassandra`: http://cassandra.apache.org/
  410. .. _`Elasticsearch`: https://aws.amazon.com/elasticsearch-service/
  411. .. _`IronCache`: http://www.iron.io/cache
  412. .. _`CouchDB`: http://www.couchdb.com/
  413. .. _`Couchbase`: http://www.couchbase.com/
  414. .. _`Consul`: http://consul.io/
  415. .. setting:: result_serializer
  416. ``result_serializer``
  417. ~~~~~~~~~~~~~~~~~~~~~
  418. Default: ``json`` since 4.0 (earlier: pickle).
  419. Result serialization format.
  420. See :ref:`calling-serializers` for information about supported
  421. serialization formats.
  422. .. setting:: result_compression
  423. ``result_compression``
  424. ~~~~~~~~~~~~~~~~~~~~~~
  425. Default: No compression.
  426. Optional compression method used for task results.
  427. Supports the same options as the :setting:`task_serializer` setting.
  428. .. setting:: result_expires
  429. ``result_expires``
  430. ~~~~~~~~~~~~~~~~~~
  431. Default: Expire after 1 day.
  432. Time (in seconds, or a :class:`~datetime.timedelta` object) for when after
  433. stored task tombstones will be deleted.
  434. A built-in periodic task will delete the results after this time
  435. (``celery.backend_cleanup``), assuming that ``celery beat`` is
  436. enabled. The task runs daily at 4am.
  437. A value of :const:`None` or 0 means results will never expire (depending
  438. on backend specifications).
  439. .. note::
  440. For the moment this only works with the AMQP, database, cache,
  441. and Redis backends.
  442. When using the database backend, ``celery beat`` must be
  443. running for the results to be expired.
  444. .. setting:: result_cache_max
  445. ``result_cache_max``
  446. ~~~~~~~~~~~~~~~~~~~~
  447. Default: Disabled by default.
  448. Enables client caching of results, which can be useful for the old deprecated
  449. 'amqp' backend where the result is unavailable as soon as one result instance
  450. consumes it.
  451. This is the total number of results to cache before older results are evicted.
  452. A value of 0 or None means no limit, and a value of :const:`-1`
  453. will disable the cache.
  454. Disabled by default.
  455. .. _conf-database-result-backend:
  456. Database backend settings
  457. -------------------------
  458. Database URL Examples
  459. ~~~~~~~~~~~~~~~~~~~~~
  460. To use the database backend you have to configure the
  461. :setting:`result_backend` setting with a connection URL and the ``db+``
  462. prefix:
  463. .. code-block:: python
  464. result_backend = 'db+scheme://user:password@host:port/dbname'
  465. Examples::
  466. # sqlite (filename)
  467. result_backend = 'db+sqlite:///results.sqlite'
  468. # mysql
  469. result_backend = 'db+mysql://scott:tiger@localhost/foo'
  470. # postgresql
  471. result_backend = 'db+postgresql://scott:tiger@localhost/mydatabase'
  472. # oracle
  473. result_backend = 'db+oracle://scott:tiger@127.0.0.1:1521/sidname'
  474. .. code-block:: python
  475. Please see `Supported Databases`_ for a table of supported databases,
  476. and `Connection String`_ for more information about connection
  477. strings (which is the part of the URI that comes after the ``db+`` prefix).
  478. .. _`Supported Databases`:
  479. http://www.sqlalchemy.org/docs/core/engines.html#supported-databases
  480. .. _`Connection String`:
  481. http://www.sqlalchemy.org/docs/core/engines.html#database-urls
  482. .. setting:: sqlalchemy_dburi
  483. ``sqlalchemy_dburi``
  484. ~~~~~~~~~~~~~~~~~~~~
  485. This setting is no longer used as it's now possible to specify
  486. the database URL directly in the :setting:`result_backend` setting.
  487. .. setting:: sqlalchemy_engine_options
  488. ``sqlalchemy_engine_options``
  489. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  490. Default: ``{}`` (empty mapping).
  491. To specify additional SQLAlchemy database engine options you can use
  492. the :setting:`sqlalchmey_engine_options` setting::
  493. # echo enables verbose logging from SQLAlchemy.
  494. app.conf.sqlalchemy_engine_options = {'echo': True}
  495. .. setting:: sqlalchemy_short_lived_sessions
  496. ``sqlalchemy_short_lived_sessions``
  497. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  498. Default: Disabled by default.
  499. Short lived sessions are disabled by default. If enabled they can drastically reduce
  500. performance, especially on systems processing lots of tasks. This option is useful
  501. on low-traffic workers that experience errors as a result of cached database connections
  502. going stale through inactivity. For example, intermittent errors like
  503. `(OperationalError) (2006, 'MySQL server has gone away')` can be fixed by enabling
  504. short lived sessions. This option only affects the database backend.
  505. .. setting:: sqlalchemy_table_names
  506. ``sqlalchemy_table_names``
  507. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  508. Default: ``{}`` (empty mapping).
  509. When SQLAlchemy is configured as the result backend, Celery automatically
  510. creates two tables to store result meta-data for tasks. This setting allows
  511. you to customize the table names:
  512. .. code-block:: python
  513. # use custom table names for the database result backend.
  514. sqlalchemy_table_names = {
  515. 'task': 'myapp_taskmeta',
  516. 'group': 'myapp_groupmeta',
  517. }
  518. .. _conf-rpc-result-backend:
  519. RPC backend settings
  520. --------------------
  521. .. setting:: result_exchange
  522. ``result_exchange``
  523. ~~~~~~~~~~~~~~~~~~~
  524. Default: ``"celeryresults"``
  525. Name of the exchange to publish results in.
  526. .. setting:: result_exchange_type
  527. ``result_exchange_type``
  528. ~~~~~~~~~~~~~~~~~~~~~~~~
  529. Default: ``"direct"``
  530. The exchange type of the result exchange.
  531. .. setting:: result_persistent
  532. ``result_persistent``
  533. ~~~~~~~~~~~~~~~~~~~~~
  534. Default: Disabled by default (transient messages).
  535. If set to :const:`True`, result messages will be persistent. This means the
  536. messages won't be lost after a broker restart.
  537. Example configuration
  538. ~~~~~~~~~~~~~~~~~~~~~
  539. .. code-block:: python
  540. result_backend = 'rpc://'
  541. result_persistent = False
  542. .. _conf-cache-result-backend:
  543. Cache backend settings
  544. ----------------------
  545. .. note::
  546. The cache backend supports the :pypi:`pylibmc` and :pypi:`python-memcached`
  547. libraries. The latter is used only if :pypi:`pylibmc` isn't installed.
  548. Using a single Memcached server:
  549. .. code-block:: python
  550. result_backend = 'cache+memcached://127.0.0.1:11211/'
  551. Using multiple Memcached servers:
  552. .. code-block:: python
  553. result_backend = """
  554. cache+memcached://172.19.26.240:11211;172.19.26.242:11211/
  555. """.strip()
  556. The "memory" backend stores the cache in memory only:
  557. .. code-block:: python
  558. result_backend = 'cache'
  559. cache_backend = 'memory'
  560. .. setting:: cache_backend_options
  561. ``cache_backend_options``
  562. ~~~~~~~~~~~~~~~~~~~~~~~~~
  563. Default: ``{}`` (empty mapping).
  564. You can set :pypi:`pylibmc` options using the :setting:`cache_backend_options`
  565. setting:
  566. .. code-block:: python
  567. cache_backend_options = {
  568. 'binary': True,
  569. 'behaviors': {'tcp_nodelay': True},
  570. }
  571. .. setting:: cache_backend
  572. ``cache_backend``
  573. ~~~~~~~~~~~~~~~~~
  574. This setting is no longer used as it's now possible to specify
  575. the cache backend directly in the :setting:`result_backend` setting.
  576. .. _conf-redis-result-backend:
  577. Redis backend settings
  578. ----------------------
  579. Configuring the backend URL
  580. ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  581. .. note::
  582. The Redis backend requires the :pypi:`redis` library.
  583. To install this package use :command:`pip`:
  584. .. code-block:: console
  585. $ pip install redis
  586. This backend requires the :setting:`result_backend`
  587. setting to be set to a Redis URL::
  588. result_backend = 'redis://:password@host:port/db'
  589. For example::
  590. result_backend = 'redis://localhost/0'
  591. which is the same as::
  592. result_backend = 'redis://'
  593. The fields of the URL are defined as follows:
  594. #. ``password``
  595. Password used to connect to the database.
  596. #. ``host``
  597. Host name or IP address of the Redis server. e.g. `localhost`.
  598. #. ``port``
  599. Port to the Redis server. Default is 6379.
  600. #. ``db``
  601. Database number to use. Default is 0.
  602. The db can include an optional leading slash.
  603. .. setting:: redis_max_connections
  604. ``redis_max_connections``
  605. ~~~~~~~~~~~~~~~~~~~~~~~~~
  606. Default: No limit.
  607. Maximum number of connections available in the Redis connection
  608. pool used for sending and retrieving results.
  609. .. setting:: redis_socket_timeout
  610. ``redis_socket_timeout``
  611. ~~~~~~~~~~~~~~~~~~~~~~~~
  612. Default: 5.0 seconds.
  613. Socket timeout for connections to Redis from the result backend
  614. in seconds (int/float)
  615. .. _conf-cassandra-result-backend:
  616. Cassandra backend settings
  617. --------------------------
  618. .. note::
  619. This Cassandra backend driver requires :pypi:`cassandra-driver`.
  620. To install, use :command:`pip`:
  621. .. code-block:: console
  622. $ pip install cassandra-driver
  623. This backend requires the following configuration directives to be set.
  624. .. setting:: cassandra_servers
  625. ``cassandra_servers``
  626. ~~~~~~~~~~~~~~~~~~~~~
  627. Default: ``[]`` (empty list).
  628. List of ``host`` Cassandra servers. e.g.::
  629. cassandra_servers = ['localhost']
  630. .. setting:: cassandra_port
  631. ``cassandra_port``
  632. ~~~~~~~~~~~~~~~~~~
  633. Default: 9042.
  634. Port to contact the Cassandra servers on.
  635. .. setting:: cassandra_keyspace
  636. ``cassandra_keyspace``
  637. ~~~~~~~~~~~~~~~~~~~~~~
  638. Default: None.
  639. The key-space in which to store the results. e.g.::
  640. cassandra_keyspace = 'tasks_keyspace'
  641. .. setting:: cassandra_table
  642. ``cassandra_table``
  643. ~~~~~~~~~~~~~~~~~~~
  644. Default: None.
  645. The table (column family) in which to store the results. e.g.::
  646. cassandra_table = 'tasks'
  647. .. setting:: cassandra_read_consistency
  648. ``cassandra_read_consistency``
  649. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  650. Default: None.
  651. The read consistency used. Values can be ``ONE``, ``TWO``, ``THREE``, ``QUORUM``, ``ALL``,
  652. ``LOCAL_QUORUM``, ``EACH_QUORUM``, ``LOCAL_ONE``.
  653. .. setting:: cassandra_write_consistency
  654. ``cassandra_write_consistency``
  655. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  656. Default: None.
  657. The write consistency used. Values can be ``ONE``, ``TWO``, ``THREE``, ``QUORUM``, ``ALL``,
  658. ``LOCAL_QUORUM``, ``EACH_QUORUM``, ``LOCAL_ONE``.
  659. .. setting:: cassandra_entry_ttl
  660. ``cassandra_entry_ttl``
  661. ~~~~~~~~~~~~~~~~~~~~~~~
  662. Default: None.
  663. Time-to-live for status entries. They will expire and be removed after that many seconds
  664. after adding. A value of :const:`None` (default) means they will never expire.
  665. .. setting:: cassandra_auth_provider
  666. ``cassandra_auth_provider``
  667. ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  668. Default: :const:`None`.
  669. AuthProvider class within ``cassandra.auth`` module to use. Values can be
  670. ``PlainTextAuthProvider`` or ``SaslAuthProvider``.
  671. .. setting:: cassandra_auth_kwargs
  672. ``cassandra_auth_kwargs``
  673. ~~~~~~~~~~~~~~~~~~~~~~~~~
  674. Default: ``{}`` (empty mapping).
  675. Named arguments to pass into the authentication provider. e.g.:
  676. .. code-block:: python
  677. cassandra_auth_kwargs = {
  678. username: 'cassandra',
  679. password: 'cassandra'
  680. }
  681. Example configuration
  682. ~~~~~~~~~~~~~~~~~~~~~
  683. .. code-block:: python
  684. cassandra_servers = ['localhost']
  685. cassandra_keyspace = 'celery'
  686. cassandra_table = 'tasks'
  687. cassandra_read_consistency = 'ONE'
  688. cassandra_write_consistency = 'ONE'
  689. cassandra_entry_ttl = 86400
  690. .. _conf-elasticsearch-result-backend:
  691. Elasticsearch backend settings
  692. ------------------------------
  693. To use `Elasticsearch`_ as the result backend you simply need to
  694. configure the :setting:`result_backend` setting with the correct URL.
  695. Example configuration
  696. ~~~~~~~~~~~~~~~~~~~~~
  697. .. code-block:: python
  698. result_backend = 'elasticsearch://example.com:9200/index_name/doc_type'
  699. .. _conf-riak-result-backend:
  700. Riak backend settings
  701. ---------------------
  702. .. note::
  703. The Riak backend requires the :pypi:`riak` library.
  704. To install the this package use :command:`pip`:
  705. .. code-block:: console
  706. $ pip install riak
  707. This backend requires the :setting:`result_backend`
  708. setting to be set to a Riak URL::
  709. result_backend = 'riak://host:port/bucket'
  710. For example::
  711. result_backend = 'riak://localhost/celery
  712. which is the same as::
  713. result_backend = 'riak://'
  714. The fields of the URL are defined as follows:
  715. #. ``host``
  716. Host name or IP address of the Riak server. e.g. `'localhost'`.
  717. #. ``port``
  718. Port to the Riak server using the protobuf protocol. Default is 8087.
  719. #. ``bucket``
  720. Bucket name to use. Default is `celery`.
  721. The bucket needs to be a string with ASCII characters only.
  722. Alternatively, this backend can be configured with the following configuration directives.
  723. .. setting:: riak_backend_settings
  724. ``riak_backend_settings``
  725. ~~~~~~~~~~~~~~~~~~~~~~~~~
  726. Default: ``{}`` (empty mapping).
  727. This is a dict supporting the following keys:
  728. * ``host``
  729. The host name of the Riak server. Defaults to ``"localhost"``.
  730. * ``port``
  731. The port the Riak server is listening to. Defaults to 8087.
  732. * ``bucket``
  733. The bucket name to connect to. Defaults to "celery".
  734. * ``protocol``
  735. The protocol to use to connect to the Riak server. This isn't configurable
  736. via :setting:`result_backend`
  737. .. _conf-ironcache-result-backend:
  738. IronCache backend settings
  739. --------------------------
  740. .. note::
  741. The IronCache backend requires the :pypi:`iron_celery` library:
  742. To install this package use :command:`pip`:
  743. .. code-block:: console
  744. $ pip install iron_celery
  745. IronCache is configured via the URL provided in :setting:`result_backend`, for example::
  746. result_backend = 'ironcache://project_id:token@'
  747. Or to change the cache name::
  748. ironcache:://project_id:token@/awesomecache
  749. For more information, see: https://github.com/iron-io/iron_celery
  750. .. _conf-couchbase-result-backend:
  751. Couchbase backend settings
  752. --------------------------
  753. .. note::
  754. The Couchbase backend requires the :pypi:`couchbase` library.
  755. To install this package use :command:`pip`:
  756. .. code-block:: console
  757. $ pip install couchbase
  758. This backend can be configured via the :setting:`result_backend`
  759. set to a Couchbase URL:
  760. .. code-block:: python
  761. result_backend = 'couchbase://username:password@host:port/bucket'
  762. .. setting:: couchbase_backend_settings
  763. ``couchbase_backend_settings``
  764. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  765. Default: ``{}`` (empty mapping).
  766. This is a dict supporting the following keys:
  767. * ``host``
  768. Host name of the Couchbase server. Defaults to ``localhost``.
  769. * ``port``
  770. The port the Couchbase server is listening to. Defaults to ``8091``.
  771. * ``bucket``
  772. The default bucket the Couchbase server is writing to.
  773. Defaults to ``default``.
  774. * ``username``
  775. User name to authenticate to the Couchbase server as (optional).
  776. * ``password``
  777. Password to authenticate to the Couchbase server (optional).
  778. .. _conf-couchdb-result-backend:
  779. CouchDB backend settings
  780. ------------------------
  781. .. note::
  782. The CouchDB backend requires the :pypi:`pycouchdb` library:
  783. To install this Couchbase package use :command:`pip`:
  784. .. code-block:: console
  785. $ pip install pycouchdb
  786. This backend can be configured via the :setting:`result_backend`
  787. set to a CouchDB URL::
  788. result_backend = 'couchdb://username:password@host:port/container'
  789. The URL is formed out of the following parts:
  790. * ``username``
  791. User name to authenticate to the CouchDB server as (optional).
  792. * ``password``
  793. Password to authenticate to the CouchDB server (optional).
  794. * ``host``
  795. Host name of the CouchDB server. Defaults to ``localhost``.
  796. * ``port``
  797. The port the CouchDB server is listening to. Defaults to ``8091``.
  798. * ``container``
  799. The default container the CouchDB server is writing to.
  800. Defaults to ``default``.
  801. .. _conf-filesystem-result-backend:
  802. File-system backend settings
  803. ----------------------------
  804. This backend can be configured using a file URL, for example::
  805. CELERY_RESULT_BACKEND = 'file:///var/celery/results'
  806. The configured directory needs to be shared and writable by all servers using
  807. the backend.
  808. If you're trying Celery on a single system you can simply use the backend
  809. without any further configuration. For larger clusters you could use NFS,
  810. `GlusterFS`_, CIFS, `HDFS`_ (using FUSE), or any other file-system.
  811. .. _`GlusterFS`: http://www.gluster.org/
  812. .. _`HDFS`: http://hadoop.apache.org/
  813. .. _conf-consul-result-backend:
  814. Consul K/V store backend settings
  815. ---------------------------------
  816. The Consul backend can be configured using a URL, for example:
  817. CELERY_RESULT_BACKEND = 'consul://localhost:8500/'
  818. The backend will storage results in the K/V store of Consul
  819. as individual keys.
  820. The backend supports auto expire of results using TTLs in Consul.
  821. .. _conf-messaging:
  822. Message Routing
  823. ---------------
  824. .. _conf-messaging-routing:
  825. .. setting:: task_queues
  826. ``task_queues``
  827. ~~~~~~~~~~~~~~~
  828. Default: :const:`None` (queue taken from default queue settings).
  829. Most users will not want to specify this setting and should rather use
  830. the :ref:`automatic routing facilities <routing-automatic>`.
  831. If you really want to configure advanced routing, this setting should
  832. be a list of :class:`kombu.Queue` objects the worker will consume from.
  833. Note that workers can be overridden this setting via the
  834. :option:`-Q <celery worker -Q>` option, or individual queues from this
  835. list (by name) can be excluded using the :option:`-X <celery worker -X>`
  836. option.
  837. Also see :ref:`routing-basics` for more information.
  838. The default is a queue/exchange/binding key of ``celery``, with
  839. exchange type ``direct``.
  840. See also :setting:`task_routes`
  841. .. setting:: task_routes
  842. ``task_routes``
  843. ~~~~~~~~~~~~~~~
  844. Default: :const:`None`.
  845. A list of routers, or a single router used to route tasks to queues.
  846. When deciding the final destination of a task the routers are consulted
  847. in order.
  848. A router can be specified as either:
  849. * A function with the signature ``(name, args, kwargs,
  850. options, task=None, **kwargs)``
  851. * A string which provides the path to a router function.
  852. * A dict containing router specification:
  853. Will be converted to a :class:`celery.routes.MapRoute` instance.
  854. * A list of ``(pattern, route)`` tuples:
  855. Will be converted to a :class:`celery.routes.MapRoute` instance.
  856. Examples:
  857. .. code-block:: python
  858. task_routes = {
  859. 'celery.ping': 'default',
  860. 'mytasks.add': 'cpu-bound',
  861. 'feed.tasks.*': 'feeds', # <-- glob pattern
  862. re.compile(r'(image|video)\.tasks\..*'): 'media', # <-- regex
  863. 'video.encode': {
  864. 'queue': 'video',
  865. 'exchange': 'media'
  866. 'routing_key': 'media.video.encode',
  867. },
  868. }
  869. task_routes = ('myapp.tasks.route_task', {'celery.ping': 'default})
  870. Where ``myapp.tasks.route_task`` could be:
  871. .. code-block:: python
  872. def route_task(self, name, args, kwargs, options, task=None, **kwargs):
  873. if task == 'celery.ping':
  874. return {'queue': 'default'}
  875. ``route_task`` may return a string or a dict. A string then means
  876. it's a queue name in :setting:`task_queues`, a dict means it's a custom route.
  877. When sending tasks, the routers are consulted in order. The first
  878. router that doesn't return ``None`` is the route to use. The message options
  879. is then merged with the found route settings, where the routers settings
  880. have priority.
  881. Example if :func:`~celery.execute.apply_async` has these arguments:
  882. .. code-block:: python
  883. Task.apply_async(immediate=False, exchange='video',
  884. routing_key='video.compress')
  885. and a router returns:
  886. .. code-block:: python
  887. {'immediate': True, 'exchange': 'urgent'}
  888. the final message options will be:
  889. .. code-block:: python
  890. immediate=True, exchange='urgent', routing_key='video.compress'
  891. (and any default message options defined in the
  892. :class:`~celery.task.base.Task` class)
  893. Values defined in :setting:`task_routes` have precedence over values defined in
  894. :setting:`task_queues` when merging the two.
  895. With the follow settings:
  896. .. code-block:: python
  897. task_queues = {
  898. 'cpubound': {
  899. 'exchange': 'cpubound',
  900. 'routing_key': 'cpubound',
  901. },
  902. }
  903. task_routes = {
  904. 'tasks.add': {
  905. 'queue': 'cpubound',
  906. 'routing_key': 'tasks.add',
  907. 'serializer': 'json',
  908. },
  909. }
  910. The final routing options for ``tasks.add`` will become:
  911. .. code-block:: javascript
  912. {'exchange': 'cpubound',
  913. 'routing_key': 'tasks.add',
  914. 'serializer': 'json'}
  915. See :ref:`routers` for more examples.
  916. .. setting:: task_queue_ha_policy
  917. ``task_queue_ha_policy``
  918. ~~~~~~~~~~~~~~~~~~~~~~~~
  919. :brokers: RabbitMQ
  920. Default: :const:`None`.
  921. This will set the default HA policy for a queue, and the value
  922. can either be a string (usually ``all``):
  923. .. code-block:: python
  924. task_queue_ha_policy = 'all'
  925. Using 'all' will replicate the queue to all current nodes,
  926. Or you can give it a list of nodes to replicate to:
  927. .. code-block:: python
  928. task_queue_ha_policy = ['rabbit@host1', 'rabbit@host2']
  929. Using a list will implicitly set ``x-ha-policy`` to 'nodes' and
  930. ``x-ha-policy-params`` to the given list of nodes.
  931. See http://www.rabbitmq.com/ha.html for more information.
  932. .. setting:: task_queue_max_priority
  933. ``task_queue_max_priority``
  934. ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  935. :brokers: RabbitMQ
  936. Default: :const:`None`.
  937. See :ref:`routing-options-rabbitmq-priorities`.
  938. .. setting:: worker_direct
  939. ``worker_direct``
  940. ~~~~~~~~~~~~~~~~~
  941. Default: Disabled.
  942. This option enables so that every worker has a dedicated queue,
  943. so that tasks can be routed to specific workers.
  944. The queue name for each worker is automatically generated based on
  945. the worker hostname and a ``.dq`` suffix, using the ``C.dq`` exchange.
  946. For example the queue name for the worker with node name ``w1@example.com``
  947. becomes::
  948. w1@example.com.dq
  949. Then you can route the task to the task by specifying the hostname
  950. as the routing key and the ``C.dq`` exchange::
  951. task_routes = {
  952. 'tasks.add': {'exchange': 'C.dq', 'routing_key': 'w1@example.com'}
  953. }
  954. .. setting:: task_create_missing_queues
  955. ``task_create_missing_queues``
  956. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  957. Default: Enabled.
  958. If enabled (default), any queues specified that aren't defined in
  959. :setting:`task_queues` will be automatically created. See
  960. :ref:`routing-automatic`.
  961. .. setting:: task_default_queue
  962. ``task_default_queue``
  963. ~~~~~~~~~~~~~~~~~~~~~~
  964. Default: ``"celery"``.
  965. The name of the default queue used by `.apply_async` if the message has
  966. no route or no custom queue has been specified.
  967. This queue must be listed in :setting:`task_queues`.
  968. If :setting:`task_queues` isn't specified then it's automatically
  969. created containing one queue entry, where this name is used as the name of
  970. that queue.
  971. .. seealso::
  972. :ref:`routing-changing-default-queue`
  973. .. setting:: task_default_exchange
  974. ``task_default_exchange``
  975. ~~~~~~~~~~~~~~~~~~~~~~~~~
  976. Default: ``"celery"``.
  977. Name of the default exchange to use when no custom exchange is
  978. specified for a key in the :setting:`task_queues` setting.
  979. .. setting:: task_default_exchange_type
  980. ``task_default_exchange_type``
  981. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  982. Default: ``"direct"``.
  983. Default exchange type used when no custom exchange type is specified
  984. for a key in the :setting:`task_queues` setting.
  985. .. setting:: task_default_routing_key
  986. ``task_default_routing_key``
  987. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  988. Default: ``"celery"``.
  989. The default routing key used when no custom routing key
  990. is specified for a key in the :setting:`task_queues` setting.
  991. .. setting:: task_default_delivery_mode
  992. ``task_default_delivery_mode``
  993. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  994. Default: ``"persistent"``.
  995. Can be `transient` (messages not written to disk) or `persistent` (written to
  996. disk).
  997. .. _conf-broker-settings:
  998. Broker Settings
  999. ---------------
  1000. .. setting:: broker_url
  1001. ``broker_url``
  1002. ~~~~~~~~~~~~~~
  1003. Default: ``"amqp://"``
  1004. Default broker URL. This must be a URL in the form of::
  1005. transport://userid:password@hostname:port/virtual_host
  1006. Only the scheme part (``transport://``) is required, the rest
  1007. is optional, and defaults to the specific transports default values.
  1008. The transport part is the broker implementation to use, and the
  1009. default is ``amqp``, which uses ``librabbitmq`` by default or falls back to
  1010. ``pyamqp`` if that's not installed. Also there are many other choices including
  1011. ``redis``, ``beanstalk``, ``sqlalchemy``, ``django``, ``mongodb``,
  1012. ``couchdb``.
  1013. It can also be a fully qualified path to your own transport implementation.
  1014. More than one broker URL, of the same transport, can also be specified.
  1015. The broker URLs can be passed in as a single string that's semicolon delimited::
  1016. broker_url = 'transport://userid:password@hostname:port//;transport://userid:password@hostname:port//'
  1017. Or as a list::
  1018. broker_url = [
  1019. 'transport://userid:password@localhost:port//',
  1020. 'transport://userid:password@hostname:port//'
  1021. ]
  1022. The brokers will then be used in the :setting:`broker_failover_strategy`.
  1023. See :ref:`kombu:connection-urls` in the Kombu documentation for more
  1024. information.
  1025. .. setting:: broker_read_url
  1026. .. setting:: broker_write_url
  1027. ``broker_read_url`` / ``broker_write_url``
  1028. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1029. Default: Taken from :setting:`broker_url`.
  1030. These settings can be configured, instead of :setting:`broker_url` to specify
  1031. different connection parameters for broker connections used for consuming and
  1032. producing.
  1033. Example::
  1034. broker_read_url = 'amqp://user:pass@broker.example.com:56721'
  1035. broker_write_url = 'amqp://user:pass@broker.example.com:56722'
  1036. Both options can also be specified as a list for failover alternates, see
  1037. :setting:`broker_url` for more information.
  1038. .. setting:: broker_failover_strategy
  1039. ``broker_failover_strategy``
  1040. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1041. Default: ``"round-robin"``.
  1042. Default failover strategy for the broker Connection object. If supplied,
  1043. may map to a key in 'kombu.connection.failover_strategies', or be a reference
  1044. to any method that yields a single item from a supplied list.
  1045. Example::
  1046. # Random failover strategy
  1047. def random_failover_strategy(servers):
  1048. it = list(it) # don't modify callers list
  1049. shuffle = random.shuffle
  1050. for _ in repeat(None):
  1051. shuffle(it)
  1052. yield it[0]
  1053. broker_failover_strategy = random_failover_strategy
  1054. .. setting:: broker_heartbeat
  1055. ``broker_heartbeat``
  1056. ~~~~~~~~~~~~~~~~~~~~
  1057. :transports supported: ``pyamqp``
  1058. Default: Disabled by default.
  1059. It's not always possible to detect connection loss in a timely
  1060. manner using TCP/IP alone, so AMQP defines something called heartbeats
  1061. that's is used both by the client and the broker to detect if
  1062. a connection was closed.
  1063. If the heartbeat value is 10 seconds, then
  1064. the heartbeat will be monitored at the interval specified
  1065. by the :setting:`broker_heartbeat_checkrate` setting, which by default is
  1066. double the rate of the heartbeat value
  1067. (so for the default 10 seconds, the heartbeat is checked every 5 seconds).
  1068. .. setting:: broker_heartbeat_checkrate
  1069. ``broker_heartbeat_checkrate``
  1070. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1071. :transports supported: ``pyamqp``
  1072. Default: 2.0.
  1073. At intervals the worker will monitor that the broker hasn't missed
  1074. too many heartbeats. The rate at which this is checked is calculated
  1075. by dividing the :setting:`broker_heartbeat` value with this value,
  1076. so if the heartbeat is 10.0 and the rate is the default 2.0, the check
  1077. will be performed every 5 seconds (twice the heartbeat sending rate).
  1078. .. setting:: broker_use_ssl
  1079. ``broker_use_ssl``
  1080. ~~~~~~~~~~~~~~~~~~
  1081. :transports supported: ``pyamqp``, ``redis``
  1082. Default: Disabled.
  1083. Toggles SSL usage on broker connection and SSL settings.
  1084. If ``True`` the connection will use SSL with default SSL settings.
  1085. If set to a dict, will configure SSL connection according to the specified
  1086. policy. The format used is Python's :func:`ssl.wrap_socket` options.
  1087. Note that SSL socket is generally served on a separate port by the broker.
  1088. Example providing a client cert and validating the server cert against a custom
  1089. certificate authority:
  1090. .. code-block:: python
  1091. import ssl
  1092. broker_use_ssl = {
  1093. 'keyfile': '/var/ssl/private/worker-key.pem',
  1094. 'certfile': '/var/ssl/amqp-server-cert.pem',
  1095. 'ca_certs': '/var/ssl/myca.pem',
  1096. 'cert_reqs': ssl.CERT_REQUIRED
  1097. }
  1098. .. warning::
  1099. Be careful using ``broker_use_ssl=True``. It's possible that your default
  1100. configuration won't validate the server cert at all. Please read Python
  1101. `ssl module security
  1102. considerations <https://docs.python.org/3/library/ssl.html#ssl-security>`_.
  1103. .. setting:: broker_pool_limit
  1104. ``broker_pool_limit``
  1105. ~~~~~~~~~~~~~~~~~~~~~
  1106. .. versionadded:: 2.3
  1107. Default: 10.
  1108. The maximum number of connections that can be open in the connection pool.
  1109. The pool is enabled by default since version 2.5, with a default limit of ten
  1110. connections. This number can be tweaked depending on the number of
  1111. threads/green-threads (eventlet/gevent) using a connection. For example
  1112. running eventlet with 1000 greenlets that use a connection to the broker,
  1113. contention can arise and you should consider increasing the limit.
  1114. If set to :const:`None` or 0 the connection pool will be disabled and
  1115. connections will be established and closed for every use.
  1116. .. setting:: broker_connection_timeout
  1117. ``broker_connection_timeout``
  1118. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1119. Default: 4.0.
  1120. The default timeout in seconds before we give up establishing a connection
  1121. to the AMQP server. This setting is disabled when using
  1122. gevent.
  1123. .. setting:: broker_connection_retry
  1124. ``broker_connection_retry``
  1125. ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1126. Default: Enabled.
  1127. Automatically try to re-establish the connection to the AMQP broker if lost.
  1128. The time between retries is increased for each retry, and is
  1129. not exhausted before :setting:`broker_connection_max_retries` is
  1130. exceeded.
  1131. .. setting:: broker_connection_max_retries
  1132. ``broker_connection_max_retries``
  1133. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1134. Default: 100.
  1135. Maximum number of retries before we give up re-establishing a connection
  1136. to the AMQP broker.
  1137. If this is set to :const:`0` or :const:`None`, we'll retry forever.
  1138. .. setting:: broker_login_method
  1139. ``broker_login_method``
  1140. ~~~~~~~~~~~~~~~~~~~~~~~
  1141. Default: ``"AMQPLAIN"``.
  1142. Set custom amqp login method.
  1143. .. setting:: broker_transport_options
  1144. ``broker_transport_options``
  1145. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1146. .. versionadded:: 2.2
  1147. Default: ``{}`` (empty mapping).
  1148. A dict of additional options passed to the underlying transport.
  1149. See your transport user manual for supported options (if any).
  1150. Example setting the visibility timeout (supported by Redis and SQS
  1151. transports):
  1152. .. code-block:: python
  1153. broker_transport_options = {'visibility_timeout': 18000} # 5 hours
  1154. .. _conf-worker:
  1155. Worker
  1156. ------
  1157. .. setting:: imports
  1158. ``imports``
  1159. ~~~~~~~~~~~
  1160. Default: ``[]`` (empty list).
  1161. A sequence of modules to import when the worker starts.
  1162. This is used to specify the task modules to import, but also
  1163. to import signal handlers and additional remote control commands, etc.
  1164. The modules will be imported in the original order.
  1165. .. setting:: include
  1166. ``include``
  1167. ~~~~~~~~~~~
  1168. Default: ``[]`` (empty list).
  1169. Exact same semantics as :setting:`imports`, but can be used as a means
  1170. to have different import categories.
  1171. The modules in this setting are imported after the modules in
  1172. :setting:`imports`.
  1173. .. _conf-concurrency:
  1174. .. setting:: worker_concurrency
  1175. ``worker_concurrency``
  1176. ~~~~~~~~~~~~~~~~~~~~~~
  1177. Default: Number of CPU cores.
  1178. The number of concurrent worker processes/threads/green threads executing
  1179. tasks.
  1180. If you're doing mostly I/O you can have more processes,
  1181. but if mostly CPU-bound, try to keep it close to the
  1182. number of CPUs on your machine. If not set, the number of CPUs/cores
  1183. on the host will be used.
  1184. .. setting:: worker_prefetch_multiplier
  1185. ``worker_prefetch_multiplier``
  1186. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1187. Default: 4.
  1188. How many messages to prefetch at a time multiplied by the number of
  1189. concurrent processes. The default is 4 (four messages for each
  1190. process). The default setting is usually a good choice, however -- if you
  1191. have very long running tasks waiting in the queue and you have to start the
  1192. workers, note that the first worker to start will receive four times the
  1193. number of messages initially. Thus the tasks may not be fairly distributed
  1194. to the workers.
  1195. To disable prefetching, set :setting:`worker_prefetch_multiplier` to 1.
  1196. Changing that setting to 0 will allow the worker to keep consuming
  1197. as many messages as it wants.
  1198. For more on prefetching, read :ref:`optimizing-prefetch-limit`
  1199. .. note::
  1200. Tasks with ETA/countdown aren't affected by prefetch limits.
  1201. .. setting:: worker_lost_wait
  1202. ``worker_lost_wait``
  1203. ~~~~~~~~~~~~~~~~~~~~
  1204. Default: 10.0 seconds.
  1205. In some cases a worker may be killed without proper cleanup,
  1206. and the worker may have published a result before terminating.
  1207. This value specifies how long we wait for any missing results before
  1208. raising a :exc:`@WorkerLostError` exception.
  1209. .. setting:: worker_max_tasks_per_child
  1210. ``worker_max_tasks_per_child``
  1211. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1212. Maximum number of tasks a pool worker process can execute before
  1213. it's replaced with a new one. Default is no limit.
  1214. .. setting:: worker_max_memory_per_child
  1215. ``worker_max_memory_per_child``
  1216. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1217. Default: No limit.
  1218. Maximum amount of resident memory that may be consumed by a
  1219. worker before it will be replaced by a new worker. If a single
  1220. task causes a worker to exceed this limit, the task will be
  1221. completed, and the worker will be replaced afterwards.
  1222. .. setting:: worker_disable_rate_limits
  1223. ``worker_disable_rate_limits``
  1224. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1225. Default: Disabled (rate limits enabled).
  1226. Disable all rate limits, even if tasks has explicit rate limits set.
  1227. .. setting:: worker_state_db
  1228. ``worker_state_db``
  1229. ~~~~~~~~~~~~~~~~~~~
  1230. Default: :const:`None`.
  1231. Name of the file used to stores persistent worker state (like revoked tasks).
  1232. Can be a relative or absolute path, but be aware that the suffix `.db`
  1233. may be appended to the file name (depending on Python version).
  1234. Can also be set via the :option:`celery worker --statedb` argument.
  1235. .. setting:: worker_timer_precision
  1236. ``worker_timer_precision``
  1237. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  1238. Default: 1.0 seconds.
  1239. Set the maximum time in seconds that the ETA scheduler can sleep between
  1240. rechecking the schedule.
  1241. Setting this value to 1 second means the schedulers precision will
  1242. be 1 second. If you need near millisecond precision you can set this to 0.1.
  1243. .. setting:: worker_enable_remote_control
  1244. ``worker_enable_remote_control``
  1245. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1246. Default: Enabled by default.
  1247. Specify if remote control of the workers is enabled.
  1248. .. _conf-events:
  1249. Events
  1250. ------
  1251. .. setting:: worker_send_task_events
  1252. ``worker_send_task_events``
  1253. ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1254. Default: Disabled by default.
  1255. Send task-related events so that tasks can be monitored using tools like
  1256. `flower`. Sets the default value for the workers
  1257. :option:`-E <celery worker -E>` argument.
  1258. .. setting:: task_send_sent_event
  1259. ``task_send_sent_event``
  1260. ~~~~~~~~~~~~~~~~~~~~~~~~
  1261. .. versionadded:: 2.2
  1262. Default: Disabled by default.
  1263. If enabled, a :event:`task-sent` event will be sent for every task so tasks can be
  1264. tracked before they're consumed by a worker.
  1265. .. setting:: event_queue_ttl
  1266. ``event_queue_ttl``
  1267. ~~~~~~~~~~~~~~~~~~~
  1268. :transports supported: ``amqp``
  1269. Default: 5.0 seconds.
  1270. Message expiry time in seconds (int/float) for when messages sent to a monitor clients
  1271. event queue is deleted (``x-message-ttl``)
  1272. For example, if this value is set to 10 then a message delivered to this queue
  1273. will be deleted after 10 seconds.
  1274. .. setting:: event_queue_expires
  1275. ``event_queue_expires``
  1276. ~~~~~~~~~~~~~~~~~~~~~~~
  1277. :transports supported: ``amqp``
  1278. Default: 60.0 seconds.
  1279. Expiry time in seconds (int/float) for when after a monitor clients
  1280. event queue will be deleted (``x-expires``).
  1281. .. setting:: event_queue_prefix
  1282. ``event_queue_prefix``
  1283. ~~~~~~~~~~~~~~~~~~~~~~
  1284. Default: ``"celeryev"``.
  1285. The prefix to use for event receiver queue names.
  1286. .. setting:: event_serializer
  1287. ``event_serializer``
  1288. ~~~~~~~~~~~~~~~~~~~~
  1289. Default: ``"json"``.
  1290. Message serialization format used when sending event messages.
  1291. .. seealso::
  1292. :ref:`calling-serializers`.
  1293. .. _conf-logging:
  1294. Logging
  1295. -------
  1296. .. setting:: worker_hijack_root_logger
  1297. ``worker_hijack_root_logger``
  1298. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1299. .. versionadded:: 2.2
  1300. Default: Enabled by default (hijack root logger).
  1301. By default any previously configured handlers on the root logger will be
  1302. removed. If you want to customize your own logging handlers, then you
  1303. can disable this behavior by setting
  1304. `worker_hijack_root_logger = False`.
  1305. .. note::
  1306. Logging can also be customized by connecting to the
  1307. :signal:`celery.signals.setup_logging` signal.
  1308. .. setting:: worker_log_color
  1309. ``worker_log_color``
  1310. ~~~~~~~~~~~~~~~~~~~~
  1311. Default: Enabled if app is logging to a terminal.
  1312. Enables/disables colors in logging output by the Celery apps.
  1313. .. setting:: worker_log_format
  1314. ``worker_log_format``
  1315. ~~~~~~~~~~~~~~~~~~~~~
  1316. Default:
  1317. .. code-block:: text
  1318. "[%(asctime)s: %(levelname)s/%(processName)s] %(message)s"
  1319. The format to use for log messages.
  1320. See the Python :mod:`logging` module for more information about log
  1321. formats.
  1322. .. setting:: worker_task_log_format
  1323. ``worker_task_log_format``
  1324. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  1325. Default:
  1326. .. code-block:: text
  1327. "[%(asctime)s: %(levelname)s/%(processName)s]
  1328. [%(task_name)s(%(task_id)s)] %(message)s"
  1329. The format to use for log messages logged in tasks.
  1330. See the Python :mod:`logging` module for more information about log
  1331. formats.
  1332. .. setting:: worker_redirect_stdouts
  1333. ``worker_redirect_stdouts``
  1334. ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1335. Default: Enabled by default.
  1336. If enabled `stdout` and `stderr` will be redirected
  1337. to the current logger.
  1338. Used by :program:`celery worker` and :program:`celery beat`.
  1339. .. setting:: worker_redirect_stdouts_level
  1340. ``worker_redirect_stdouts_level``
  1341. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1342. Default: :const:`WARNING`.
  1343. The log level output to `stdout` and `stderr` is logged as.
  1344. Can be one of :const:`DEBUG`, :const:`INFO`, :const:`WARNING`,
  1345. :const:`ERROR`, or :const:`CRITICAL`.
  1346. .. _conf-security:
  1347. Security
  1348. --------
  1349. .. setting:: security_key
  1350. ``security_key``
  1351. ~~~~~~~~~~~~~~~~
  1352. Default: :const:`None`.
  1353. .. versionadded:: 2.5
  1354. The relative or absolute path to a file containing the private key
  1355. used to sign messages when :ref:`message-signing` is used.
  1356. .. setting:: security_certificate
  1357. ``security_certificate``
  1358. ~~~~~~~~~~~~~~~~~~~~~~~~
  1359. Default: :const:`None`.
  1360. .. versionadded:: 2.5
  1361. The relative or absolute path to an X.509 certificate file
  1362. used to sign messages when :ref:`message-signing` is used.
  1363. .. setting:: security_cert_store
  1364. ``security_cert_store``
  1365. ~~~~~~~~~~~~~~~~~~~~~~~
  1366. Default: :const:`None`.
  1367. .. versionadded:: 2.5
  1368. The directory containing X.509 certificates used for
  1369. :ref:`message-signing`. Can be a glob with wild-cards,
  1370. (for example :file:`/etc/certs/*.pem`).
  1371. .. _conf-custom-components:
  1372. Custom Component Classes (advanced)
  1373. -----------------------------------
  1374. .. setting:: worker_pool
  1375. ``worker_pool``
  1376. ~~~~~~~~~~~~~~~
  1377. Default: ``"prefork"`` (``celery.concurrency.prefork:TaskPool``).
  1378. Name of the pool class used by the worker.
  1379. .. admonition:: Eventlet/Gevent
  1380. Never use this option to select the eventlet or gevent pool.
  1381. You must use the :option:`-P <celery worker -P>` option to
  1382. :program:`celery worker` instead, to ensure the monkey patches
  1383. aren't applied too late, causing things to break in strange ways.
  1384. .. setting:: worker_pool_restarts
  1385. ``worker_pool_restarts``
  1386. ~~~~~~~~~~~~~~~~~~~~~~~~
  1387. Default: Disabled by default.
  1388. If enabled the worker pool can be restarted using the
  1389. :control:`pool_restart` remote control command.
  1390. .. setting:: worker_consumer
  1391. ``worker_consumer``
  1392. ~~~~~~~~~~~~~~~~~~~
  1393. Default: ``"celery.worker.consumer:Consumer"``.
  1394. Name of the consumer class used by the worker.
  1395. .. setting:: worker_timer
  1396. ``worker_timer``
  1397. ~~~~~~~~~~~~~~~~
  1398. Default: ``"kombu.async.hub.timer:Timer"``.
  1399. Name of the ETA scheduler class used by the worker.
  1400. Default is or set by the pool implementation.
  1401. .. _conf-celerybeat:
  1402. Beat Settings (:program:`celery beat`)
  1403. --------------------------------------
  1404. .. setting:: beat_schedule
  1405. ``beat_schedule``
  1406. ~~~~~~~~~~~~~~~~~
  1407. Default: ``{}`` (empty mapping).
  1408. The periodic task schedule used by :mod:`~celery.bin.beat`.
  1409. See :ref:`beat-entries`.
  1410. .. setting:: beat_scheduler
  1411. ``beat_scheduler``
  1412. ~~~~~~~~~~~~~~~~~~
  1413. Default: ``"celery.beat:PersistentScheduer"``.
  1414. The default scheduler class.
  1415. Can also be set via the :option:`celery beat -S` argument.
  1416. .. setting:: beat_schedule_filename
  1417. ``beat_schedule_filename``
  1418. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  1419. Default: ``"celerybeat-schedule"``.
  1420. Name of the file used by `PersistentScheduler` to store the last run times
  1421. of periodic tasks. Can be a relative or absolute path, but be aware that the
  1422. suffix `.db` may be appended to the file name (depending on Python version).
  1423. Can also be set via the :option:`celery beat --schedule` argument.
  1424. .. setting:: beat_sync_every
  1425. ``beat_sync_every``
  1426. ~~~~~~~~~~~~~~~~~~~
  1427. Default: 0.
  1428. The number of periodic tasks that can be called before another database sync
  1429. is issued.
  1430. A value of 0 (default) means sync based on timing - default of 3 minutes as determined by
  1431. scheduler.sync_every. If set to 1, beat will call sync after every task
  1432. message sent.
  1433. .. setting:: beat_max_loop_interval
  1434. ``beat_max_loop_interval``
  1435. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  1436. Default: 0.
  1437. The maximum number of seconds :mod:`~celery.bin.beat` can sleep
  1438. between checking the schedule.
  1439. The default for this value is scheduler specific.
  1440. For the default Celery beat scheduler the value is 300 (5 minutes),
  1441. but for e.g. the :pypi:`django-celery` database scheduler it's 5 seconds
  1442. because the schedule may be changed externally, and so it must take
  1443. changes to the schedule into account.
  1444. Also when running Celery beat embedded (:option:`-B <celery worker -B>`)
  1445. on Jython as a thread the max interval is overridden and set to 1 so
  1446. that it's possible to shut down in a timely manner.