configuration.rst 64 KB

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