You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
fastapi_celery/main.py

23 lines
333 B
Python

from celery import Celery
from fastapi import FastAPI
app = FastAPI()
celery = Celery(
__name__, broker="redis://127.0.0.1:6379/0", backend="redis://127.0.0.1:6379/0"
)
@app.get("/")
async def root():
return {"message": "Hello World"}
@celery.task
def divide(x, y):
import time
time.sleep(5)
return x / y