Celery knowledge

One: packaging
 
Celery decorative instance object class is a decorator
from celery import Celery 
Timer
from celery.schedules import crontab
celery also provides a class expression analysis results obtained, the simplified expression crontab
from celery.schedules import crontab_parser
 
II: instance of an object
broker = 'redis://:xxx'
backend = 'redis://:xxx'
app = Celery('mytask', broker=broker, backend=backend)
# Parameters a: mytask, the name of the current module, the module will only __main__ name when defining the production tasks.
# Parameter Two: broker middleware is a message transmission, the broker has several options to choose from: RabbitMQ (Message Queue), Redis (cache database), database (not recommended), and so on.
# Three parameters: backend, messages are usually sent by a program, finished on the end, you may not know when they accept, and to this end, celery implemented a backend, for storing messages and some messages celery execution and results , backend Celery is a configuration item in the configuration CELERY_RESULT_BACKEND, save the results and the role of the state, if you need to track the status of tasks, you need to set up this one, can be a Database backend, can also be a Cache backend.
 
app.conf.CELERY_TIMEZONE = 'Asia/Shanghai'
app.conf.CELERY_ENABLE_UTC = True
 
# EVERYTHING

Guess you like

Origin www.cnblogs.com/meloncodezhang/p/12511908.html