Replies: 1 comment
|
Your Compose file starts Uvicorn and Redis, but doesn't start a Taskiq worker. Run a separate worker using the module path from your example: taskiq worker app.main:brokerFor Compose, add a worker service using the same image/build, mounted code, and Also adjust the startup/shutdown handlers. The FastAPI integration runs app startup inside worker processes too, so don't submit and wait for your test task unconditionally there. A worker could end up waiting for a task before its consumer has started. Keep those handlers focused on the API-side broker lifecycle: @app.on_event("startup")
async def startup_event():
if not broker.is_worker_process:
await broker.startup()
@app.on_event("shutdown")
async def shutdown_event():
if not broker.is_worker_process:
await broker.shutdown()Notice the Once both processes are running, enqueue your test from a request handler or a separate producer, then await its result if needed. The integration documentation shows the lifecycle guards. Newer FastAPI applications should express the same lifecycle using a lifespan handler; the decorators above match the style in your existing example. |
Uh oh!
There was an error while loading. Please reload this page.
Hi, I'm very interested in getting Taskiq setup for my FastAPI project but am having trouble setting it up for even a basic test. If anyone could take a look to tell me what i'm doing wrong that would be very helpful.
I'm trying to using Redis for both queuing tasks and as the results backend. It's working successfully as a results backend when I use the InMemoryBroker to kiq, but the task doesn't get triggered when I use ListQueueBroker to kiq. Not sure what I'm doing wrong.
Here's the relevant code in my main.py:
Here's my docker-compose for reference as well:
All reactions