An example to run flask with celery including:
- app factory setup
- send a long running task from flask app
- send periodic tasks with celery beat
based on flask-celery-example by Miguel Grinberg and his bloc article
- / adds a task to the queue and schedule it to start in 10 seconds
- /message - shows messages in the database (revered every 10 seconds by celery task)
- /status/<task_id> - show the status of the long running task
install dependencies with poetry
poetry install
poetry shell
docker run -d --name redis -p 6379:6379 redis
source .env
celery -A src.worker:celery worker --loglevel=DEBUG
source .env
celery -A src.worker:celery beat --loglevel=INFO
source .env
# check the available routes
flask routes
# start flask development server
flask run