Nebularazer Flask Celery Example Save

Example for using Celery 4 with Flask (App Factory) and Periodic Tasks with Celery Beat

Project README

flask-celery-example

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

endpoints

  • / 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

installation

install dependencies with poetry

poetry install
poetry shell

start redis backend (using docker)

docker run -d --name redis -p 6379:6379 redis

run celery worker

source .env
celery -A src.worker:celery worker --loglevel=DEBUG

run celery beat for periodic tasks

source .env
celery -A src.worker:celery beat --loglevel=INFO

run flask app

source .env
# check the available routes
flask routes
# start flask development server
flask run
Open Source Agenda is not affiliated with "Nebularazer Flask Celery Example" Project. README Source: nebularazer/flask-celery-example
Stars
65
Open Issues
5
Last Commit
1 year ago

Open Source Agenda Badge

Open Source Agenda Rating