aioredis under uvicorn with uvloop question

387 views Asked by At

I have a question. If I use aioredis together with FastAPI using uvicorn and set uvloop in the --loop argument, will aioredis use uvloop or pure asyncio?

from fastapi import FastAPI
app = FastAPI()


@app.get('/get/{key}')
async def get_from_redis(key):
    redis = aioredis.from_url('redis://127.0.0.1')
    value = await redis.get(key)  # uses uvloop or pure asyncio?
    return {'response': value}
uvicorn main:app --workers 2 --loop uvloop
1

There are 1 answers

0
Marcelo Trylesinski On BEST ANSWER

It will use uvloop.

Uvicorn runs asyncio.set_event_loop_policy(uvloop.EventLoopPolicy()) before starting the application.