Background task does not start in FastApi, Arq

21 Views Asked by At

Colleagues, who can help, my stack: Python 3.10, arq 0.25, redis. why is the background task arq not running? A key like this appears in redis "arq:job:32646989261645a4a164815cc34dfee5", no errors when requesting a route (return 202)

from arq import create_pool
from arq.connections import RedisSettings

@app.get("/api/integration/test")
async def test(current_user: Annotated [GetUsersDTO, Depends(get_current_user)], response: Response):
    pool = await create_pool(RedisSettings(host=host, password=password))
    async with pool as pool:
        await pool.enqueue_job("task", current_user[0].id)
    response.status_code = status.HTTP_202_ACCEPTED
    return {"message": "start..."}

async def task(ctx, user_id):
    log_id, err = await insert_log({'users_id': user_id, 'work': 'start'})
    for i in range(30):
        print(i)
        time.sleep(5)
0

There are 0 best solutions below