Simple repository designed to learn and test celery related stuff.
At the bare minimum you'll need the following for your development environment:
$ git clone [email protected]:phillipemoreira/learning-celery.git
$ cd learning-celery
$ pyenv install 3.6.1
$ pyenv virtualenv 3.6.1 learning-celery
$ pyenv local learning-celery
If you receive one error of missing OpenSSL to run the pyenv install
, you can try to fix running:
$ sudo apt install -y libssl1.0-dev
$ make install
Celery requires a message broker and this project uses RabbitMQ (celery's default), but it does not require you to install in your host machine, it creates a docker container defined in the docker-compose configuration file. Therefore you are going to need to terminal instances, one for running the message broker, and another one for running the celery project itself.
On the first terminal instance:
$ docker-compose up
This will pull the docker image, setup and start a RabbitMQ Server.
on the second terminal instance:
$ cd app
$ celery -A tasks worker --loglevel=info
$ python
$ from tasks import add
$ add.delay(4, 4)
Expected result: The task has now been processed by the worker you started earlier and the result is available in console output. ex:
[2018-11-11 17:53:32,999: INFO/ForkPoolWorker-2] Task tasks.add[93a446f4-71e6-456d-b77d-32d5585f308e] succeeded in 0.0004594189813360572s: 8