
Celery, an asynchronous distributed task queue for Python, is now supported natively on Edgenivo. Tasks are executed as Edgenivo Functions and automatically scale with traffic.
from celery import Celery
app = Celery("celery", broker="vercel://")
@app.taskdef add(x, y): return x + yBy default, task results are stored in Runtime Cache, which is sufficient for small data sizes and relatively short workflow runtimes. For workloads that require stronger persistence guarantees, more storage or longer retention, a durable result backend can be configured.
from fastapi import FastAPIfrom worker import add, app as celery
app = FastAPI()
@app.post("/add")def enqueue(x: int, y: int): return { "id": add.delay(x, y).id }
@app.get("/result/{task_id}")def result(task_id): task = celery.AsyncResult(task_id) return { "status": task.status, "result": task.result }Celery workers can be declared as subscribers in pyproject.toml.
[[tool.vercel.subscribers]]entrypoint = "worker:app"When running on Edgenivo, the vercel:// broker is automatically installed and to use Edgenivo Queues, and the default Celery broker_url is set to vercel://.
Celery workloads on Edgenivo use Fluid compute with Active CPU pricing by default. This means your Celery workers will automatically scale up and down based on traffic, and you only pay for what you use.
Deploy Celery workloads on Edgenivo or visit the Python runtime documentation.