configuration.rst 59 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224
  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. .. warning:
  385. While the AMQP result backend is very efficient, you must make sure
  386. you only receive the same result once. See :doc:`userguide/calling`).
  387. .. _`SQLAlchemy`: http://sqlalchemy.org
  388. .. _`memcached`: http://memcached.org
  389. .. _`MongoDB`: http://mongodb.org
  390. .. _`Redis`: http://redis.io
  391. .. _`Cassandra`: http://cassandra.apache.org/
  392. .. _`IronCache`: http://www.iron.io/cache
  393. .. _`CouchDB`: http://www.couchdb.com/
  394. .. _`Couchbase`: http://www.couchbase.com/
  395. .. setting:: result_serializer
  396. result_serializer
  397. ~~~~~~~~~~~~~~~~~
  398. Result serialization format. Default is ``pickle``. See
  399. :ref:`calling-serializers` for information about supported
  400. serialization formats.
  401. .. setting:: result_compression
  402. result_compression
  403. ~~~~~~~~~~~~~~~~~~
  404. Optional compression method used for task results.
  405. Supports the same options as the :setting:`task_serializer` setting.
  406. Default is no compression.
  407. .. setting:: result_expires
  408. result_expires
  409. ~~~~~~~~~~~~~~
  410. Time (in seconds, or a :class:`~datetime.timedelta` object) for when after
  411. stored task tombstones will be deleted.
  412. A built-in periodic task will delete the results after this time
  413. (``celery.backend_cleanup``), assuming that ``celery beat`` is
  414. enabled. The task runs daily at 4am.
  415. A value of :const:`None` or 0 means results will never expire (depending
  416. on backend specifications).
  417. Default is to expire after 1 day.
  418. .. note::
  419. For the moment this only works with the amqp, database, cache, redis and MongoDB
  420. backends.
  421. When using the database or MongoDB backends, `celery beat` must be
  422. running for the results to be expired.
  423. .. setting:: result_cache_max
  424. result_cache_max
  425. ~~~~~~~~~~~~~~~~
  426. Result backends caches ready results used by the client.
  427. This is the total number of results to cache before older results are evicted.
  428. The default is 5000. 0 or None means no limit, and a value of :const:`-1`
  429. will disable the cache.
  430. .. _conf-database-result-backend:
  431. Database backend settings
  432. -------------------------
  433. Database URL Examples
  434. ~~~~~~~~~~~~~~~~~~~~~
  435. To use the database backend you have to configure the
  436. :setting:`result_backend` setting with a connection URL and the ``db+``
  437. prefix:
  438. .. code-block:: python
  439. result_backend = 'db+scheme://user:password@host:port/dbname'
  440. Examples::
  441. # sqlite (filename)
  442. result_backend = 'db+sqlite:///results.sqlite'
  443. # mysql
  444. result_backend = 'db+mysql://scott:tiger@localhost/foo'
  445. # postgresql
  446. result_backend = 'db+postgresql://scott:tiger@localhost/mydatabase'
  447. # oracle
  448. result_backend = 'db+oracle://scott:tiger@127.0.0.1:1521/sidname'
  449. .. code-block:: python
  450. Please see `Supported Databases`_ for a table of supported databases,
  451. and `Connection String`_ for more information about connection
  452. strings (which is the part of the URI that comes after the ``db+`` prefix).
  453. .. _`Supported Databases`:
  454. http://www.sqlalchemy.org/docs/core/engines.html#supported-databases
  455. .. _`Connection String`:
  456. http://www.sqlalchemy.org/docs/core/engines.html#database-urls
  457. .. setting:: sqlalchemy_dburi
  458. sqlalchemy_dburi
  459. ~~~~~~~~~~~~~~~~
  460. This setting is no longer used as it's now possible to specify
  461. the database URL directly in the :setting:`result_backend` setting.
  462. .. setting:: sqlalchemy_engine_options
  463. sqlalchemy_engine_options
  464. ~~~~~~~~~~~~~~~~~~~~~~~~~
  465. To specify additional SQLAlchemy database engine options you can use
  466. the :setting:`sqlalchmey_engine_options` setting::
  467. # echo enables verbose logging from SQLAlchemy.
  468. sqlalchemy_engine_options = {'echo': True}
  469. .. setting:: sqlalchemy_short_lived_sessions
  470. sqlalchemy_short_lived_sessions
  471. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  472. sqlalchemy_short_lived_sessions = True
  473. Short lived sessions are disabled by default. If enabled they can drastically reduce
  474. performance, especially on systems processing lots of tasks. This option is useful
  475. on low-traffic workers that experience errors as a result of cached database connections
  476. going stale through inactivity. For example, intermittent errors like
  477. `(OperationalError) (2006, 'MySQL server has gone away')` can be fixed by enabling
  478. short lived sessions. This option only affects the database backend.
  479. .. setting:: sqlalchemy_table_names
  480. sqlalchemy_table_names
  481. ~~~~~~~~~~~~~~~~~~~~~~
  482. When SQLAlchemy is configured as the result backend, Celery automatically
  483. creates two tables to store result metadata for tasks. This setting allows
  484. you to customize the table names:
  485. .. code-block:: python
  486. # use custom table names for the database result backend.
  487. sqlalchemy_table_names = {
  488. 'task': 'myapp_taskmeta',
  489. 'group': 'myapp_groupmeta',
  490. }
  491. .. _conf-rpc-result-backend:
  492. RPC backend settings
  493. --------------------
  494. .. setting:: result_persistent
  495. result_persistent
  496. ~~~~~~~~~~~~~~~~~
  497. If set to :const:`True`, result messages will be persistent. This means the
  498. messages will not be lost after a broker restart. The default is for the
  499. results to be transient.
  500. Example configuration
  501. ~~~~~~~~~~~~~~~~~~~~~
  502. .. code-block:: python
  503. result_backend = 'rpc://'
  504. result_persistent = False
  505. .. _conf-cache-result-backend:
  506. Cache backend settings
  507. ----------------------
  508. .. note::
  509. The cache backend supports the `pylibmc`_ and `python-memcached`
  510. libraries. The latter is used only if `pylibmc`_ is not installed.
  511. Using a single memcached server:
  512. .. code-block:: python
  513. result_backend = 'cache+memcached://127.0.0.1:11211/'
  514. Using multiple memcached servers:
  515. .. code-block:: python
  516. result_backend = """
  517. cache+memcached://172.19.26.240:11211;172.19.26.242:11211/
  518. """.strip()
  519. The "memory" backend stores the cache in memory only:
  520. .. code-block:: python
  521. result_backend = 'cache'
  522. cache_backend = 'memory'
  523. .. setting:: cache_backend_options
  524. cache_backend_options
  525. ~~~~~~~~~~~~~~~~~~~~~
  526. You can set pylibmc options using the :setting:`cache_backend_options`
  527. setting:
  528. .. code-block:: python
  529. cache_backend_options = {
  530. 'binary': True,
  531. 'behaviors': {'tcp_nodelay': True},
  532. }
  533. .. _`pylibmc`: http://sendapatch.se/projects/pylibmc/
  534. .. setting:: cache_backend
  535. cache_backend
  536. ~~~~~~~~~~~~~
  537. This setting is no longer used as it's now possible to specify
  538. the cache backend directly in the :setting:`result_backend` setting.
  539. .. _conf-redis-result-backend:
  540. Redis backend settings
  541. ----------------------
  542. Configuring the backend URL
  543. ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  544. .. note::
  545. The Redis backend requires the :mod:`redis` library:
  546. http://pypi.python.org/pypi/redis/
  547. To install the redis package use `pip` or `easy_install`:
  548. .. code-block:: console
  549. $ pip install redis
  550. This backend requires the :setting:`result_backend`
  551. setting to be set to a Redis URL::
  552. result_backend = 'redis://:password@host:port/db'
  553. For example::
  554. result_backend = 'redis://localhost/0'
  555. which is the same as::
  556. result_backend = 'redis://'
  557. The fields of the URL are defined as follows:
  558. - *host*
  559. Host name or IP address of the Redis server. e.g. `localhost`.
  560. - *port*
  561. Port to the Redis server. Default is 6379.
  562. - *db*
  563. Database number to use. Default is 0.
  564. The db can include an optional leading slash.
  565. - *password*
  566. Password used to connect to the database.
  567. .. setting:: redis_max_connections
  568. redis_max_connections
  569. ~~~~~~~~~~~~~~~~~~~~~
  570. Maximum number of connections available in the Redis connection
  571. pool used for sending and retrieving results.
  572. .. setting:: redis_socket_timeout
  573. redis_socket_timeout
  574. ~~~~~~~~~~~~~~~~~~~~
  575. Socket timeout for connections to Redis from the result backend
  576. in seconds (int/float)
  577. Default is 5 seconds.
  578. .. _conf-mongodb-result-backend:
  579. MongoDB backend settings
  580. ------------------------
  581. .. note::
  582. The MongoDB backend requires the :mod:`pymongo` library:
  583. http://github.com/mongodb/mongo-python-driver/tree/master
  584. .. setting:: mongodb_backend_settings
  585. mongodb_backend_settings
  586. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  587. This is a dict supporting the following keys:
  588. * database
  589. The database name to connect to. Defaults to ``celery``.
  590. * taskmeta_collection
  591. The collection name to store task meta data.
  592. Defaults to ``celery_taskmeta``.
  593. * max_pool_size
  594. Passed as max_pool_size to PyMongo's Connection or MongoClient
  595. constructor. It is the maximum number of TCP connections to keep
  596. open to MongoDB at a given time. If there are more open connections
  597. than max_pool_size, sockets will be closed when they are released.
  598. Defaults to 10.
  599. * options
  600. Additional keyword arguments to pass to the mongodb connection
  601. constructor. See the :mod:`pymongo` docs to see a list of arguments
  602. supported.
  603. .. _example-mongodb-result-config:
  604. Example configuration
  605. ~~~~~~~~~~~~~~~~~~~~~
  606. .. code-block:: python
  607. result_backend = 'mongodb://192.168.1.100:30000/'
  608. mongodb_backend_settings = {
  609. 'database': 'mydb',
  610. 'taskmeta_collection': 'my_taskmeta_collection',
  611. }
  612. .. _conf-cassandra-result-backend:
  613. cassandra backend settings
  614. --------------------------
  615. .. note::
  616. This Cassandra backend driver requires :mod:`cassandra-driver`.
  617. https://pypi.python.org/pypi/cassandra-driver
  618. To install, use `pip` or `easy_install`:
  619. .. code-block:: bash
  620. $ pip install cassandra-driver
  621. This backend requires the following configuration directives to be set.
  622. .. setting:: cassandra_servers
  623. cassandra_servers
  624. ~~~~~~~~~~~~~~~~~
  625. List of ``host`` Cassandra servers. e.g.::
  626. cassandra_servers = ['localhost']
  627. .. setting:: cassandra_port
  628. cassandra_port
  629. ~~~~~~~~~~~~~~
  630. Port to contact the Cassandra servers on. Default is 9042.
  631. .. setting:: cassandra_keyspace
  632. cassandra_keyspace
  633. ~~~~~~~~~~~~~~~~~~
  634. The keyspace in which to store the results. e.g.::
  635. cassandra_keyspace = 'tasks_keyspace'
  636. .. setting:: cassandra_table
  637. cassandra_table
  638. ~~~~~~~~~~~~~~~
  639. The table (column family) in which to store the results. e.g.::
  640. cassandra_table = 'tasks'
  641. .. setting:: cassandra_read_consistency
  642. cassandra_read_consistency
  643. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  644. The read consistency used. Values can be ``ONE``, ``TWO``, ``THREE``, ``QUORUM``, ``ALL``,
  645. ``LOCAL_QUORUM``, ``EACH_QUORUM``, ``LOCAL_ONE``.
  646. .. setting:: cassandra_write_consistency
  647. cassandra_write_consistency
  648. ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  649. The write consistency used. Values can be ``ONE``, ``TWO``, ``THREE``, ``QUORUM``, ``ALL``,
  650. ``LOCAL_QUORUM``, ``EACH_QUORUM``, ``LOCAL_ONE``.
  651. .. setting:: cassandra_entry_ttl
  652. cassandra_entry_ttl
  653. ~~~~~~~~~~~~~~~~~~~
  654. Time-to-live for status entries. They will expire and be removed after that many seconds
  655. after adding. Default (None) means they will never expire.
  656. Example configuration
  657. ~~~~~~~~~~~~~~~~~~~~~
  658. .. code-block:: python
  659. cassandra_servers = ['localhost']
  660. cassandra_keyspace = 'celery'
  661. cassandra_table = 'tasks'
  662. cassandra_read_consistency = 'ONE'
  663. cassandra_write_consistency = 'ONE'
  664. cassandra_entry_ttl = 86400
  665. .. _conf-riak-result-backend:
  666. Riak backend settings
  667. ---------------------
  668. .. note::
  669. The Riak backend requires the :mod:`riak` library:
  670. http://pypi.python.org/pypi/riak/
  671. To install the riak package use `pip` or `easy_install`:
  672. .. code-block:: console
  673. $ pip install riak
  674. This backend requires the :setting:`result_backend`
  675. setting to be set to a Riak URL::
  676. result_backend = "riak://host:port/bucket"
  677. For example::
  678. result_backend = "riak://localhost/celery
  679. which is the same as::
  680. result_backend = "riak://"
  681. The fields of the URL are defined as follows:
  682. - *host*
  683. Host name or IP address of the Riak server. e.g. `"localhost"`.
  684. - *port*
  685. Port to the Riak server using the protobuf protocol. Default is 8087.
  686. - *bucket*
  687. Bucket name to use. Default is `celery`.
  688. The bucket needs to be a string with ascii characters only.
  689. Altenatively, this backend can be configured with the following configuration directives.
  690. .. setting:: riak_backend_settings
  691. riak_backend_settings
  692. ~~~~~~~~~~~~~~~~~~~~~
  693. This is a dict supporting the following keys:
  694. * host
  695. The host name of the Riak server. Defaults to "localhost".
  696. * port
  697. The port the Riak server is listening to. Defaults to 8087.
  698. * bucket
  699. The bucket name to connect to. Defaults to "celery".
  700. * protocol
  701. The protocol to use to connect to the Riak server. This is not configurable
  702. via :setting:`result_backend`
  703. .. _conf-ironcache-result-backend:
  704. IronCache backend settings
  705. --------------------------
  706. .. note::
  707. The IronCache backend requires the :mod:`iron_celery` library:
  708. http://pypi.python.org/pypi/iron_celery
  709. To install the iron_celery package use `pip` or `easy_install`:
  710. .. code-block:: console
  711. $ pip install iron_celery
  712. IronCache is configured via the URL provided in :setting:`result_backend`, for example::
  713. result_backend = 'ironcache://project_id:token@'
  714. Or to change the cache name::
  715. ironcache:://project_id:token@/awesomecache
  716. For more information, see: https://github.com/iron-io/iron_celery
  717. .. _conf-couchbase-result-backend:
  718. Couchbase backend settings
  719. --------------------------
  720. .. note::
  721. The Couchbase backend requires the :mod:`couchbase` library:
  722. https://pypi.python.org/pypi/couchbase
  723. To install the couchbase package use `pip` or `easy_install`:
  724. .. code-block:: console
  725. $ pip install couchbase
  726. This backend can be configured via the :setting:`result_backend`
  727. set to a couchbase URL::
  728. result_backend = 'couchbase://username:password@host:port/bucket'
  729. .. setting:: couchbase_backend_settings
  730. couchbase_backend_settings
  731. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  732. This is a dict supporting the following keys:
  733. * host
  734. Host name of the Couchbase server. Defaults to ``localhost``.
  735. * port
  736. The port the Couchbase server is listening to. Defaults to ``8091``.
  737. * bucket
  738. The default bucket the Couchbase server is writing to.
  739. Defaults to ``default``.
  740. * username
  741. User name to authenticate to the Couchbase server as (optional).
  742. * password
  743. Password to authenticate to the Couchbase server (optional).
  744. .. _conf-couchdb-result-backend:
  745. CouchDB backend settings
  746. ------------------------
  747. .. note::
  748. The CouchDB backend requires the :mod:`pycouchdb` library:
  749. https://pypi.python.org/pypi/pycouchdb
  750. To install the couchbase package use `pip` or `easy_install`:
  751. .. code-block:: console
  752. $ pip install pycouchdb
  753. This backend can be configured via the :setting:`result_backend`
  754. set to a couchdb URL::
  755. result_backend = 'couchdb://username:password@host:port/container'
  756. The URL is formed out of the following parts:
  757. * username
  758. User name to authenticate to the CouchDB server as (optional).
  759. * password
  760. Password to authenticate to the CouchDB server (optional).
  761. * host
  762. Host name of the CouchDB server. Defaults to ``localhost``.
  763. * port
  764. The port the CouchDB server is listening to. Defaults to ``8091``.
  765. * container
  766. The default container the CouchDB server is writing to.
  767. Defaults to ``default``.
  768. .. _conf-amqp-result-backend:
  769. AMQP backend settings
  770. ---------------------
  771. .. admonition:: Do not use in production.
  772. This is the old AMQP result backend that creates one queue per task,
  773. if you want to send results back as message please consider using the
  774. RPC backend instead, or if you need the results to be persistent
  775. use a result backend designed for that purpose (e.g. Redis, or a database).
  776. .. note::
  777. The AMQP backend requires RabbitMQ 1.1.0 or higher to automatically
  778. expire results. If you are running an older version of RabbitMQ
  779. you should disable result expiration like this:
  780. result_expires = None
  781. .. setting:: result_exchange
  782. result_exchange
  783. ~~~~~~~~~~~~~~~
  784. Name of the exchange to publish results in. Default is `celeryresults`.
  785. .. setting:: result_exchange_type
  786. result_exchange_type
  787. ~~~~~~~~~~~~~~~~~~~~
  788. The exchange type of the result exchange. Default is to use a `direct`
  789. exchange.
  790. result_persistent
  791. ~~~~~~~~~~~~~~~~~
  792. If set to :const:`True`, result messages will be persistent. This means the
  793. messages will not be lost after a broker restart. The default is for the
  794. results to be transient.
  795. Example configuration
  796. ~~~~~~~~~~~~~~~~~~~~~
  797. .. code-block:: python
  798. result_backend = 'amqp'
  799. result_expires = 18000 # 5 hours.
  800. .. _conf-messaging:
  801. Message Routing
  802. ---------------
  803. .. _conf-messaging-routing:
  804. .. setting:: task_queues
  805. task_queues
  806. ~~~~~~~~~~~
  807. Most users will not want to specify this setting and should rather use
  808. the :ref:`automatic routing facilities <routing-automatic>`.
  809. If you really want to configure advanced routing, this setting should
  810. be a list of :class:`kombu.Queue` objects the worker will consume from.
  811. Note that workers can be overriden this setting via the `-Q` option,
  812. or individual queues from this list (by name) can be excluded using
  813. the `-X` option.
  814. Also see :ref:`routing-basics` for more information.
  815. The default is a queue/exchange/binding key of ``celery``, with
  816. exchange type ``direct``.
  817. See also :setting:`task_routes`
  818. .. setting:: task_routes
  819. task_routes
  820. ~~~~~~~~~~~~~
  821. A list of routers, or a single router used to route tasks to queues.
  822. When deciding the final destination of a task the routers are consulted
  823. in order.
  824. A router can be specified as either:
  825. * A router class instances
  826. * A string which provides the path to a router class
  827. * A dict containing router specification. It will be converted to a :class:`celery.routes.MapRoute` instance.
  828. Examples:
  829. .. code-block:: python
  830. task_routes = {
  831. "celery.ping": "default",
  832. "mytasks.add": "cpu-bound",
  833. "video.encode": {
  834. "queue": "video",
  835. "exchange": "media"
  836. "routing_key": "media.video.encode",
  837. },
  838. }
  839. task_routes = ("myapp.tasks.Router", {"celery.ping": "default})
  840. Where ``myapp.tasks.Router`` could be:
  841. .. code-block:: python
  842. class Router(object):
  843. def route_for_task(self, task, args=None, kwargs=None):
  844. if task == "celery.ping":
  845. return "default"
  846. ``route_for_task`` may return a string or a dict. A string then means
  847. it's a queue name in :setting:`task_queues`, a dict means it's a custom route.
  848. When sending tasks, the routers are consulted in order. The first
  849. router that doesn't return ``None`` is the route to use. The message options
  850. is then merged with the found route settings, where the routers settings
  851. have priority.
  852. Example if :func:`~celery.execute.apply_async` has these arguments:
  853. .. code-block:: python
  854. Task.apply_async(immediate=False, exchange="video",
  855. routing_key="video.compress")
  856. and a router returns:
  857. .. code-block:: python
  858. {"immediate": True, "exchange": "urgent"}
  859. the final message options will be:
  860. .. code-block:: python
  861. immediate=True, exchange="urgent", routing_key="video.compress"
  862. (and any default message options defined in the
  863. :class:`~celery.task.base.Task` class)
  864. Values defined in :setting:`task_routes` have precedence over values defined in
  865. :setting:`task_queues` when merging the two.
  866. With the follow settings:
  867. .. code-block:: python
  868. task_queues = {
  869. "cpubound": {
  870. "exchange": "cpubound",
  871. "routing_key": "cpubound",
  872. },
  873. }
  874. task_routes = {
  875. "tasks.add": {
  876. "queue": "cpubound",
  877. "routing_key": "tasks.add",
  878. "serializer": "json",
  879. },
  880. }
  881. The final routing options for ``tasks.add`` will become:
  882. .. code-block:: javascript
  883. {"exchange": "cpubound",
  884. "routing_key": "tasks.add",
  885. "serializer": "json"}
  886. See :ref:`routers` for more examples.
  887. .. setting:: task_queue_ha_policy
  888. task_queue_ha_policy
  889. ~~~~~~~~~~~~~~~~~~~~
  890. :brokers: RabbitMQ
  891. This will set the default HA policy for a queue, and the value
  892. can either be a string (usually ``all``):
  893. .. code-block:: python
  894. task_queue_ha_policy = 'all'
  895. Using 'all' will replicate the queue to all current nodes,
  896. Or you can give it a list of nodes to replicate to:
  897. .. code-block:: python
  898. task_queue_ha_policy = ['rabbit@host1', 'rabbit@host2']
  899. Using a list will implicitly set ``x-ha-policy`` to 'nodes' and
  900. ``x-ha-policy-params`` to the given list of nodes.
  901. See http://www.rabbitmq.com/ha.html for more information.
  902. .. setting:: worker_direct
  903. worker_direct
  904. ~~~~~~~~~~~~~
  905. This option enables so that every worker has a dedicated queue,
  906. so that tasks can be routed to specific workers.
  907. The queue name for each worker is automatically generated based on
  908. the worker hostname and a ``.dq`` suffix, using the ``C.dq`` exchange.
  909. For example the queue name for the worker with node name ``w1@example.com``
  910. becomes::
  911. w1@example.com.dq
  912. Then you can route the task to the task by specifying the hostname
  913. as the routing key and the ``C.dq`` exchange::
  914. task_routes = {
  915. 'tasks.add': {'exchange': 'C.dq', 'routing_key': 'w1@example.com'}
  916. }
  917. .. setting:: task_create_missing_queues
  918. task_create_missing_queues
  919. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  920. If enabled (default), any queues specified that are not defined in
  921. :setting:`task_queues` will be automatically created. See
  922. :ref:`routing-automatic`.
  923. .. setting:: task_default_queue
  924. task_default_queue
  925. ~~~~~~~~~~~~~~~~~~
  926. The name of the default queue used by `.apply_async` if the message has
  927. no route or no custom queue has been specified.
  928. This queue must be listed in :setting:`task_queues`.
  929. If :setting:`task_queues` is not specified then it is automatically
  930. created containing one queue entry, where this name is used as the name of
  931. that queue.
  932. The default is: `celery`.
  933. .. seealso::
  934. :ref:`routing-changing-default-queue`
  935. .. setting:: task_default_exchange
  936. task_default_exchange
  937. ~~~~~~~~~~~~~~~~~~~~~
  938. Name of the default exchange to use when no custom exchange is
  939. specified for a key in the :setting:`task_queues` setting.
  940. The default is: `celery`.
  941. .. setting:: task_default_exchange_type
  942. task_default_exchange_type
  943. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  944. Default exchange type used when no custom exchange type is specified
  945. for a key in the :setting:`task_queues` setting.
  946. The default is: `direct`.
  947. .. setting:: task_default_routing_key
  948. task_default_routing_key
  949. ~~~~~~~~~~~~~~~~~~~~~~~~
  950. The default routing key used when no custom routing key
  951. is specified for a key in the :setting:`task_queues` setting.
  952. The default is: `celery`.
  953. .. setting:: task_default_delivery_mode
  954. task_default_delivery_mode
  955. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  956. Can be `transient` or `persistent`. The default is to send
  957. persistent messages.
  958. .. _conf-broker-settings:
  959. Broker Settings
  960. ---------------
  961. .. setting:: broker_url
  962. broker_url
  963. ~~~~~~~~~~
  964. Default broker URL. This must be an URL in the form of::
  965. transport://userid:password@hostname:port/virtual_host
  966. Only the scheme part (``transport://``) is required, the rest
  967. is optional, and defaults to the specific transports default values.
  968. The transport part is the broker implementation to use, and the
  969. default is ``amqp``, which uses ``librabbitmq`` by default or falls back to
  970. ``pyamqp`` if that is not installed. Also there are many other choices including
  971. ``redis``, ``beanstalk``, ``sqlalchemy``, ``django``, ``mongodb``,
  972. ``couchdb``.
  973. It can also be a fully qualified path to your own transport implementation.
  974. More than broker URL, of the same transport, can also be specified.
  975. The broker URLs can be passed in as a single string that is semicolon delimited::
  976. broker_url = 'transport://userid:password@hostname:port//;transport://userid:password@hostname:port//'
  977. Or as a list::
  978. broker_url = [
  979. 'transport://userid:password@localhost:port//',
  980. 'transport://userid:password@hostname:port//'
  981. ]
  982. The brokers will then be used in the :setting:`broker_failover_strategy`.
  983. See :ref:`kombu:connection-urls` in the Kombu documentation for more
  984. information.
  985. .. setting:: broker_failover_strategy
  986. broker_failover_strategy
  987. ~~~~~~~~~~~~~~~~~~~~~~~~
  988. Default failover strategy for the broker Connection object. If supplied,
  989. may map to a key in 'kombu.connection.failover_strategies', or be a reference
  990. to any method that yields a single item from a supplied list.
  991. Example::
  992. # Random failover strategy
  993. def random_failover_strategy(servers):
  994. it = list(it) # don't modify callers list
  995. shuffle = random.shuffle
  996. for _ in repeat(None):
  997. shuffle(it)
  998. yield it[0]
  999. broker_failover_strategy = random_failover_strategy
  1000. .. setting:: broker_heartbeat
  1001. broker_heartbeat
  1002. ~~~~~~~~~~~~~~~~
  1003. :transports supported: ``pyamqp``
  1004. It's not always possible to detect connection loss in a timely
  1005. manner using TCP/IP alone, so AMQP defines something called heartbeats
  1006. that's is used both by the client and the broker to detect if
  1007. a connection was closed.
  1008. Heartbeats are disabled by default.
  1009. If the heartbeat value is 10 seconds, then
  1010. the heartbeat will be monitored at the interval specified
  1011. by the :setting:`broker_heartbeat_checkrate` setting, which by default is
  1012. double the rate of the heartbeat value
  1013. (so for the default 10 seconds, the heartbeat is checked every 5 seconds).
  1014. .. setting:: broker_heartbeat_checkrate
  1015. broker_heartbeat_checkrate
  1016. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  1017. :transports supported: ``pyamqp``
  1018. At intervals the worker will monitor that the broker has not missed
  1019. too many heartbeats. The rate at which this is checked is calculated
  1020. by dividing the :setting:`broker_heartbeat` value with this value,
  1021. so if the heartbeat is 10.0 and the rate is the default 2.0, the check
  1022. will be performed every 5 seconds (twice the heartbeat sending rate).
  1023. .. setting:: broker_use_ssl
  1024. broker_use_ssl
  1025. ~~~~~~~~~~~~~~
  1026. :transports supported: ``pyamqp``, ``redis``
  1027. Toggles SSL usage on broker connection and SSL settings.
  1028. If ``True`` the connection will use SSL with default SSL settings.
  1029. If set to a dict, will configure SSL connection according to the specified
  1030. policy. The format used is python `ssl.wrap_socket()
  1031. options <https://docs.python.org/3/library/ssl.html#ssl.wrap_socket>`_.
  1032. Default is ``False`` (no SSL).
  1033. Note that SSL socket is generally served on a separate port by the broker.
  1034. Example providing a client cert and validating the server cert against a custom
  1035. certificate authority:
  1036. .. code-block:: python
  1037. import ssl
  1038. broker_use_ssl = {
  1039. 'keyfile': '/var/ssl/private/worker-key.pem',
  1040. 'certfile': '/var/ssl/amqp-server-cert.pem',
  1041. 'ca_certs': '/var/ssl/myca.pem',
  1042. 'cert_reqs': ssl.CERT_REQUIRED
  1043. }
  1044. .. warning::
  1045. Be careful using ``broker_use_ssl=True``, it is possible that your default
  1046. configuration do not validate the server cert at all, please read Python
  1047. `ssl module security
  1048. considerations <https://docs.python.org/3/library/ssl.html#ssl-security>`_.
  1049. .. setting:: broker_pool_limit
  1050. broker_pool_limit
  1051. ~~~~~~~~~~~~~~~~~
  1052. .. versionadded:: 2.3
  1053. The maximum number of connections that can be open in the connection pool.
  1054. The pool is enabled by default since version 2.5, with a default limit of ten
  1055. connections. This number can be tweaked depending on the number of
  1056. threads/greenthreads (eventlet/gevent) using a connection. For example
  1057. running eventlet with 1000 greenlets that use a connection to the broker,
  1058. contention can arise and you should consider increasing the limit.
  1059. If set to :const:`None` or 0 the connection pool will be disabled and
  1060. connections will be established and closed for every use.
  1061. Default (since 2.5) is to use a pool of 10 connections.
  1062. .. setting:: broker_connection_timeout
  1063. broker_connection_timeout
  1064. ~~~~~~~~~~~~~~~~~~~~~~~~~
  1065. The default timeout in seconds before we give up establishing a connection
  1066. to the AMQP server. Default is 4 seconds.
  1067. .. setting:: broker_connection_retry
  1068. broker_connection_retry
  1069. ~~~~~~~~~~~~~~~~~~~~~~~
  1070. Automatically try to re-establish the connection to the AMQP broker if lost.
  1071. The time between retries is increased for each retry, and is
  1072. not exhausted before :setting:`broker_connection_max_retries` is
  1073. exceeded.
  1074. This behavior is on by default.
  1075. .. setting:: broker_connection_max_retries
  1076. broker_connection_max_retries
  1077. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1078. Maximum number of retries before we give up re-establishing a connection
  1079. to the AMQP broker.
  1080. If this is set to :const:`0` or :const:`None`, we will retry forever.
  1081. Default is 100 retries.
  1082. .. setting:: broker_login_method
  1083. broker_login_method
  1084. ~~~~~~~~~~~~~~~~~~~
  1085. Set custom amqp login method, default is ``AMQPLAIN``.
  1086. .. setting:: broker_transport_options
  1087. broker_transport_options
  1088. ~~~~~~~~~~~~~~~~~~~~~~~~
  1089. .. versionadded:: 2.2
  1090. A dict of additional options passed to the underlying transport.
  1091. See your transport user manual for supported options (if any).
  1092. Example setting the visibility timeout (supported by Redis and SQS
  1093. transports):
  1094. .. code-block:: python
  1095. broker_transport_options = {'visibility_timeout': 18000} # 5 hours
  1096. .. _conf-worker:
  1097. Worker
  1098. ------
  1099. .. setting:: imports
  1100. imports
  1101. ~~~~~~~
  1102. A sequence of modules to import when the worker starts.
  1103. This is used to specify the task modules to import, but also
  1104. to import signal handlers and additional remote control commands, etc.
  1105. The modules will be imported in the original order.
  1106. .. setting:: include
  1107. include
  1108. ~~~~~~~
  1109. Exact same semantics as :setting:`imports`, but can be used as a means
  1110. to have different import categories.
  1111. The modules in this setting are imported after the modules in
  1112. :setting:`imports`.
  1113. .. _conf-concurrency:
  1114. .. setting:: worker_concurrency
  1115. worker_concurrency
  1116. ~~~~~~~~~~~~~~~~~~
  1117. The number of concurrent worker processes/threads/green threads executing
  1118. tasks.
  1119. If you're doing mostly I/O you can have more processes,
  1120. but if mostly CPU-bound, try to keep it close to the
  1121. number of CPUs on your machine. If not set, the number of CPUs/cores
  1122. on the host will be used.
  1123. Defaults to the number of available CPUs.
  1124. .. setting:: worker_prefetch_multiplier
  1125. worker_prefetch_multiplier
  1126. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  1127. How many messages to prefetch at a time multiplied by the number of
  1128. concurrent processes. The default is 4 (four messages for each
  1129. process). The default setting is usually a good choice, however -- if you
  1130. have very long running tasks waiting in the queue and you have to start the
  1131. workers, note that the first worker to start will receive four times the
  1132. number of messages initially. Thus the tasks may not be fairly distributed
  1133. to the workers.
  1134. To disable prefetching, set :setting:`worker_prefetch_multiplier` to 1.
  1135. Changing that setting to 0 will allow the worker to keep consuming
  1136. as many messages as it wants.
  1137. For more on prefetching, read :ref:`optimizing-prefetch-limit`
  1138. .. note::
  1139. Tasks with ETA/countdown are not affected by prefetch limits.
  1140. .. setting:: worker_lost_wait
  1141. worker_lost_wait
  1142. ~~~~~~~~~~~~~~~~
  1143. In some cases a worker may be killed without proper cleanup,
  1144. and the worker may have published a result before terminating.
  1145. This value specifies how long we wait for any missing results before
  1146. raising a :exc:`@WorkerLostError` exception.
  1147. Default is 10.0
  1148. .. setting:: worker_max_tasks_per_child
  1149. worker_max_tasks_per_child
  1150. ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1151. Maximum number of tasks a pool worker process can execute before
  1152. it's replaced with a new one. Default is no limit.
  1153. .. setting:: worker_max_memory_per_child
  1154. worker_max_memory_per_child
  1155. ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1156. Maximum amount of resident memory that may be consumed by a
  1157. worker before it will be replaced by a new worker. If a single
  1158. task causes a worker to exceed this limit, the task will be
  1159. completed, and the worker will be replaced afterwards. Default:
  1160. no limit.
  1161. .. setting:: worker_disable_rate_limits
  1162. worker_disable_rate_limits
  1163. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  1164. Disable all rate limits, even if tasks has explicit rate limits set.
  1165. .. setting:: worker_state_db
  1166. worker_state_db
  1167. ~~~~~~~~~~~~~~~
  1168. Name of the file used to stores persistent worker state (like revoked tasks).
  1169. Can be a relative or absolute path, but be aware that the suffix `.db`
  1170. may be appended to the file name (depending on Python version).
  1171. Can also be set via the :option:`--statedb` argument to
  1172. :mod:`~celery.bin.worker`.
  1173. Not enabled by default.
  1174. .. setting:: worker_timer_precision
  1175. worker_timer_precision
  1176. ~~~~~~~~~~~~~~~~~~~~~~
  1177. Set the maximum time in seconds that the ETA scheduler can sleep between
  1178. rechecking the schedule. Default is 1 second.
  1179. Setting this value to 1 second means the schedulers precision will
  1180. be 1 second. If you need near millisecond precision you can set this to 0.1.
  1181. .. setting:: worker_enable_remote_control
  1182. worker_enable_remote_control
  1183. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1184. Specify if remote control of the workers is enabled.
  1185. Default is :const:`True`.
  1186. .. _conf-error-mails:
  1187. Error E-Mails
  1188. -------------
  1189. .. setting:: task_send_error_emails
  1190. task_send_error_emails
  1191. ~~~~~~~~~~~~~~~~~~~~~~
  1192. The default value for the `Task.send_error_emails` attribute, which if
  1193. set to :const:`True` means errors occurring during task execution will be
  1194. sent to :setting:`admins` by email.
  1195. Disabled by default.
  1196. .. setting:: admins
  1197. admins
  1198. ~~~~~~
  1199. List of `(name, email_address)` tuples for the administrators that should
  1200. receive error emails.
  1201. .. setting:: server_email
  1202. server_email
  1203. ~~~~~~~~~~~~
  1204. The email address this worker sends emails from.
  1205. Default is celery@localhost.
  1206. .. setting:: email_host
  1207. email_host
  1208. ~~~~~~~~~~
  1209. The mail server to use. Default is ``localhost``.
  1210. .. setting:: email_host_user
  1211. email_host_user
  1212. ~~~~~~~~~~~~~~~
  1213. User name (if required) to log on to the mail server with.
  1214. .. setting:: email_host_password
  1215. email_host_password
  1216. ~~~~~~~~~~~~~~~~~~~
  1217. Password (if required) to log on to the mail server with.
  1218. .. setting:: email_port
  1219. email_port
  1220. ~~~~~~~~~~
  1221. The port the mail server is listening on. Default is `25`.
  1222. .. setting:: email_use_ssl
  1223. email_use_ssl
  1224. ~~~~~~~~~~~~~
  1225. Use SSL when connecting to the SMTP server. Disabled by default.
  1226. .. setting:: email_use_tls
  1227. email_use_tls
  1228. ~~~~~~~~~~~~~
  1229. Use TLS when connecting to the SMTP server. Disabled by default.
  1230. .. setting:: email_timeout
  1231. email_timeout
  1232. ~~~~~~~~~~~~~
  1233. Timeout in seconds for when we give up trying to connect
  1234. to the SMTP server when sending emails.
  1235. The default is 2 seconds.
  1236. .. setting:: email_charset
  1237. email_charset
  1238. ~~~~~~~~~~~~~
  1239. .. versionadded:: 4.0
  1240. Charset for outgoing emails. Default is "us-ascii".
  1241. .. _conf-example-error-mail-config:
  1242. Example E-Mail configuration
  1243. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1244. This configuration enables the sending of error emails to
  1245. george@vandelay.com and kramer@vandelay.com:
  1246. .. code-block:: python
  1247. # Enables error emails.
  1248. task_send_error_emails = True
  1249. # Name and email addresses of recipients
  1250. admins = (
  1251. ('George Costanza', 'george@vandelay.com'),
  1252. ('Cosmo Kramer', 'kosmo@vandelay.com'),
  1253. )
  1254. # Email address used as sender (From field).
  1255. server_email = 'no-reply@vandelay.com'
  1256. # Mailserver configuration
  1257. email_host = 'mail.vandelay.com'
  1258. email_port = 25
  1259. # email_host_user = 'servers'
  1260. # email_host_password = 's3cr3t'
  1261. .. _conf-events:
  1262. Events
  1263. ------
  1264. .. setting:: worker_send_task_events
  1265. worker_send_task_events
  1266. ~~~~~~~~~~~~~~~~~~~~~~~
  1267. Send task-related events so that tasks can be monitored using tools like
  1268. `flower`. Sets the default value for the workers :option:`-E` argument.
  1269. .. setting:: task_send_sent_event
  1270. task_send_sent_event
  1271. ~~~~~~~~~~~~~~~~~~~~
  1272. .. versionadded:: 2.2
  1273. If enabled, a :event:`task-sent` event will be sent for every task so tasks can be
  1274. tracked before they are consumed by a worker.
  1275. Disabled by default.
  1276. .. setting:: event_queue_ttl
  1277. event_queue_ttl
  1278. ~~~~~~~~~~~~~~~~~~~~~~
  1279. :transports supported: ``amqp``
  1280. Message expiry time in seconds (int/float) for when messages sent to a monitor clients
  1281. event queue is deleted (``x-message-ttl``)
  1282. For example, if this value is set to 10 then a message delivered to this queue
  1283. will be deleted after 10 seconds.
  1284. Disabled by default.
  1285. .. setting:: event_queue_expires
  1286. event_queue_expires
  1287. ~~~~~~~~~~~~~~~~~~~
  1288. :transports supported: ``amqp``
  1289. Expiry time in seconds (int/float) for when after a monitor clients
  1290. event queue will be deleted (``x-expires``).
  1291. Default is never, relying on the queue autodelete setting.
  1292. .. setting:: event_serializer
  1293. event_serializer
  1294. ~~~~~~~~~~~~~~~~
  1295. Message serialization format used when sending event messages.
  1296. Default is ``json``. See :ref:`calling-serializers`.
  1297. .. _conf-logging:
  1298. Logging
  1299. -------
  1300. .. setting:: worker_hijack_root_logger
  1301. worker_hijack_root_logger
  1302. ~~~~~~~~~~~~~~~~~~~~~~~~~
  1303. .. versionadded:: 2.2
  1304. By default any previously configured handlers on the root logger will be
  1305. removed. If you want to customize your own logging handlers, then you
  1306. can disable this behavior by setting
  1307. `worker_hijack_root_logger = False`.
  1308. .. note::
  1309. Logging can also be customized by connecting to the
  1310. :signal:`celery.signals.setup_logging` signal.
  1311. .. setting:: worker_log_color
  1312. worker_log_color
  1313. ~~~~~~~~~~~~~~~~~
  1314. Enables/disables colors in logging output by the Celery apps.
  1315. By default colors are enabled if
  1316. 1) the app is logging to a real terminal, and not a file.
  1317. 2) the app is not running on Windows.
  1318. .. setting:: worker_log_format
  1319. worker_log_format
  1320. ~~~~~~~~~~~~~~~~~
  1321. The format to use for log messages.
  1322. Default is `[%(asctime)s: %(levelname)s/%(processName)s] %(message)s`
  1323. See the Python :mod:`logging` module for more information about log
  1324. formats.
  1325. .. setting:: worker_task_log_format
  1326. worker_task_log_format
  1327. ~~~~~~~~~~~~~~~~~~~~~~
  1328. The format to use for log messages logged in tasks. Can be overridden using
  1329. the :option:`--loglevel` option to :mod:`~celery.bin.worker`.
  1330. Default is::
  1331. [%(asctime)s: %(levelname)s/%(processName)s]
  1332. [%(task_name)s(%(task_id)s)] %(message)s
  1333. See the Python :mod:`logging` module for more information about log
  1334. formats.
  1335. .. setting:: worker_redirect_stdouts
  1336. worker_redirect_stdouts
  1337. ~~~~~~~~~~~~~~~~~~~~~~~
  1338. If enabled `stdout` and `stderr` will be redirected
  1339. to the current logger.
  1340. Enabled by default.
  1341. Used by :program:`celery worker` and :program:`celery beat`.
  1342. .. setting:: worker_redirect_stdouts_level
  1343. worker_redirect_stdouts_level
  1344. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1345. The log level output to `stdout` and `stderr` is logged as.
  1346. Can be one of :const:`DEBUG`, :const:`INFO`, :const:`WARNING`,
  1347. :const:`ERROR` or :const:`CRITICAL`.
  1348. Default is :const:`WARNING`.
  1349. .. _conf-security:
  1350. Security
  1351. --------
  1352. .. setting:: security_key
  1353. security_key
  1354. ~~~~~~~~~~~~
  1355. .. versionadded:: 2.5
  1356. The relative or absolute path to a file containing the private key
  1357. used to sign messages when :ref:`message-signing` is used.
  1358. .. setting:: security_certificate
  1359. security_certificate
  1360. ~~~~~~~~~~~~~~~~~~~~
  1361. .. versionadded:: 2.5
  1362. The relative or absolute path to an X.509 certificate file
  1363. used to sign messages when :ref:`message-signing` is used.
  1364. .. setting:: security_cert_store
  1365. security_cert_store
  1366. ~~~~~~~~~~~~~~~~~~~
  1367. .. versionadded:: 2.5
  1368. The directory containing X.509 certificates used for
  1369. :ref:`message-signing`. Can be a glob with wildcards,
  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. Name of the pool class used by the worker.
  1378. .. admonition:: Eventlet/Gevent
  1379. Never use this option to select the eventlet or gevent pool.
  1380. You must use the `-P` option instead, otherwise the monkey patching
  1381. will happen too late and things will break in strange and silent ways.
  1382. Default is ``celery.concurrency.prefork:TaskPool``.
  1383. .. setting:: worker_pool_restarts
  1384. worker_pool_restarts
  1385. ~~~~~~~~~~~~~~~~~~~~
  1386. If enabled the worker pool can be restarted using the
  1387. :control:`pool_restart` remote control command.
  1388. Disabled by default.
  1389. .. setting:: worker_autoscaler
  1390. worker_autoscaler
  1391. ~~~~~~~~~~~~~~~~~
  1392. .. versionadded:: 2.2
  1393. Name of the autoscaler class to use.
  1394. Default is ``celery.worker.autoscale:Autoscaler``.
  1395. .. setting:: worker_autoreloader
  1396. worker_autoreloader
  1397. ~~~~~~~~~~~~~~~~~~~
  1398. Name of the autoreloader class used by the worker to reload
  1399. Python modules and files that have changed.
  1400. Default is: ``celery.worker.autoreload:Autoreloader``.
  1401. .. setting:: worker_consumer
  1402. worker_consumer
  1403. ~~~~~~~~~~~~~~~
  1404. Name of the consumer class used by the worker.
  1405. Default is :class:`celery.worker.consumer.Consumer`
  1406. .. setting:: worker_timer
  1407. worker_timer
  1408. ~~~~~~~~~~~~
  1409. Name of the ETA scheduler class used by the worker.
  1410. Default is :class:`kombu.async.hub.timer.Timer`, or one overrided
  1411. by the pool implementation.
  1412. .. _conf-celerybeat:
  1413. Beat Settings (:program:`celery beat`)
  1414. --------------------------------------
  1415. .. setting:: beat_schedule
  1416. beat_schedule
  1417. ~~~~~~~~~~~~~
  1418. The periodic task schedule used by :mod:`~celery.bin.beat`.
  1419. See :ref:`beat-entries`.
  1420. .. setting:: beat_scheduler
  1421. beat_scheduler
  1422. ~~~~~~~~~~~~~~
  1423. The default scheduler class. Default is ``celery.beat:PersistentScheduler``.
  1424. Can also be set via the :option:`-S` argument to
  1425. :mod:`~celery.bin.beat`.
  1426. .. setting:: beat_schedule_filename
  1427. beat_schedule_filename
  1428. ~~~~~~~~~~~~~~~~~~~~~~
  1429. Name of the file used by `PersistentScheduler` to store the last run times
  1430. of periodic tasks. Can be a relative or absolute path, but be aware that the
  1431. suffix `.db` may be appended to the file name (depending on Python version).
  1432. Can also be set via the :option:`--schedule` argument to
  1433. :mod:`~celery.bin.beat`.
  1434. .. setting:: beat_sync_every
  1435. beat_sync_every
  1436. ~~~~~~~~~~~~~~~
  1437. The number of periodic tasks that can be called before another database sync
  1438. is issued.
  1439. Defaults to 0 (sync based on timing - default of 3 minutes as determined by
  1440. scheduler.sync_every). If set to 1, beat will call sync after every task
  1441. message sent.
  1442. .. setting:: beat_max_loop_interval
  1443. beat_max_loop_interval
  1444. ~~~~~~~~~~~~~~~~~~~~~~
  1445. The maximum number of seconds :mod:`~celery.bin.beat` can sleep
  1446. between checking the schedule.
  1447. The default for this value is scheduler specific.
  1448. For the default celery beat scheduler the value is 300 (5 minutes),
  1449. but for e.g. the django-celery database scheduler it is 5 seconds
  1450. because the schedule may be changed externally, and so it must take
  1451. changes to the schedule into account.
  1452. Also when running celery beat embedded (:option:`-B`) on Jython as a thread
  1453. the max interval is overridden and set to 1 so that it's possible
  1454. to shut down in a timely manner.