Install celery and rabbitmq
1) pip install celery
2) brew update
3) brew install rabbitmq
4) export PATH=$PATH:/usr/local/opt/rabbitmq/sbin
5) rabbitmq-server
Then http://localhost:15672/ will give you access.
5. Celery application has two parts:
- Workers that wait for messages from RabbitMQ and execute the tasks.
- Client that submit messages to RabbitMQ to trigger task execution, and eventually retrieve the result at a later time
6. Create a directory
7. Create a
The following line is critical:
downloaderApp to hold our new python module, and a directory downloadedFiles where the downloaded files will be stored:7. Create a
downloaderApp.py module that will contain two functions, download and list, that will be the asynchronous tasks. The following line is critical:
app = Celery('downloaderApp', backend='rpc://', broker='pyamqp://guest@localhost//')
This line creates:
- A Celery application named
downloaderApp - A
brokeron the localhost that will accept message via *Advanced Message Queuing Protocol (AMQP), the protocol used by RabbitMQ - A response
backendwhere workers will store the return value of the task so that clients can retrieve it later (remember that task execution is asynchronous). If you omitbackend, the task will still run, but the return value will be lost.rpcmeans the response will be sent to a RabbitMQ queue in a Remote Procedure Call pattern.