configuration.rst 60 KB

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