Build celery+rabbitmq Distributed task Scheduling under Window

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.