Environment Construction:
1. Install celery4.0 version above
2. Install the operating environment of Erlang because the RABBITMQ is based on the Erlang environment; Download Link: http://www.erlang.org/download.html
3. Install RABBITMQ, download link: http://www.rabbitmq.com/download.htm
Demo Test:
Create tasks.py
from Import = celery ('tasks', backend=', broker='amqp://[email protected]//') @app. Taskdef Add (x, y): return x + y
Run at the command line below the project root directory: celery-a TAS worker--loglevel=info start task
Then open the Python command-line mode:
>>>from Tasks InPort Add
>>>add.delay (1,3)
After running, the log will be printed in the CMD window.
If you run an error valueerror:need more than 0 values to unpack
Then use celery-a TAS worker--loglevel=info-p eventlet Start the task, the official website said is more than 4 version has this problem, specifically can refer to this https://github.com/celery/celery/issues/4081
fromCeleryImportCelery
App= Celery(' Tasks ',Backend="',Broker=' Amqp://[email protected]//')
@app. Task
defAdd(x,y):
returnx+ y
Build celery+rabbitmq Distributed task Scheduling under Window