Cov txheej txheem:

Dab tsi yog celery hauv Django?
Dab tsi yog celery hauv Django?

Video: Dab tsi yog celery hauv Django?

Video: Dab tsi yog celery hauv Django?
Video: Leng Yang - Yog Vim Dab Tsi (Official Full Song | Nkauj Tawm Tshiab) 2020/05/24 2024, Kaum ib hlis
Anonim

Celery yog ib txoj hauj lwm queue/ua hauj lwm queue raws li cov lus xa tawm. Nws yog tsom rau kev ua haujlwm ntawm lub sijhawm tiag tiag, tab sis txhawb kev teem sijhawm thiab. Cov haujlwm ua haujlwm, hu ua cov haujlwm, tau ua tiav ib txhij ntawm ib lossis ntau tus neeg ua haujlwm servers. Celery yog sau rau hauv Python, tab sis cov txheej txheem tuaj yeem siv tau hauv txhua hom lus.

Tsis tas li, koj siv celery hauv Django li cas?

Teeb tsa

  1. Kauj ruam 1: Ntxiv celery.py. Hauv phau ntawv "picha", tsim cov ntaub ntawv tshiab hu ua celery.py:
  2. Kauj ruam 2: Ntshuam koj tshiab Celery app. Txhawm rau kom ntseeg tau tias Celery app tau thauj khoom thaum Django pib, ntxiv cov lej hauv qab no rau hauv _init_.py cov ntaub ntawv uas zaum ntawm koj cov ntaub ntawv settings.py:
  3. Kauj ruam 3: Nruab Redis ua Celery "Broker"

Ib yam li ntawd, celery thiab Redis yog dab tsi? Redis thiab zaub celery ntawm cov tshuab cais Celery cov haujlwm yuav tsum tau hu xovtooj. Yog li muaj zaub celery tus neeg ua haujlwm ntawm lub network optimized tshuab yuav ua rau cov dej num khiav nrawm dua. Redis yog ib qho hauv-nco database, yog li feem ntau koj yuav xav tau redis khiav ntawm lub tshuab nco-optimized.

Tsis tas li ntawd, dab tsi yog tus neeg ua haujlwm hauv celery?

Cov Cov neeg ua haujlwm Celery nws tus kheej tsis ua tej hauj lwm. Nws spawns me nyuam txheej txheem (los yog threads) thiab deals nrog tag nrho cov phau ntawv khaws khoom. Tus menyuam txheej txheem (lossis xov) ua cov haujlwm tiag tiag. Cov txheej txheem menyuam yaus no (lossis cov xov) tseem hu ua lub pas dej ua tiav.

Dab tsi yog celery backend?

Celery yog Python Task-Queue system uas tswj kev faib cov haujlwm ntawm cov neeg ua haujlwm hla cov xov lossis cov kab sib txuas. Nws ua rau asynchronous tswj kev ua haujlwm yooj yim. Koj daim ntawv thov tsuas yog yuav tsum thawb cov lus mus rau a broker , zoo li RabbitMQ, thiab Celery cov neeg ua haujlwm yuav pop lawv thiab teem sijhawm ua haujlwm.

Pom zoo: