Skip to content

Latest commit

 

History

History

celery

README.md

Use CloudAMQP with Celery

A minimal Celery app using CloudAMQP, or any AMQP 0-9-1 broker such as LavinMQ or RabbitMQ, as the broker.

Usage

Tool versions are in mise.toml; with mise a virtualenv is created in .venv automatically. Otherwise use Python 3.9+ and a virtualenv.

pip install -r requirements.txt
export BROKER_URL="amqps://user:password@host/vhost"
celery -A tasks worker --without-heartbeat --without-gossip --without-mingle   # in one terminal
python publisher.py                                                           # in another

The --without-* flags stop the worker from sending heartbeat, gossip and mingle messages, which otherwise add up to hundreds of messages per second.

Without BROKER_URL it connects to amqp://guest:guest@localhost.

Tests

pytest starts an embedded worker with the settings in celeryconfig.py, and runs a task through a real broker on localhost. CI runs it against LavinMQ.

pip install -r requirements-dev.txt
pytest