The call to asyncio.get_running_loop() forces AsyncRedisSaver to be constructed in the context of a running event loop, despite not actually doing anything async in the constructor.
I have found myself forced to do the following in order to bypass this, since i cannot easily perform this construction in async-land at the moment.
def setup():
checkpointer = asyncio.run(_redis_saver(client))
...
uvicorn.run(...)
async def _redis_saver(client: Redis):
return AsyncRedisSaver(redis_client=client)
async def lifespan():
checkpointer.loop = asyncio.get_event_loop()
await checkpointer.asetup()
The call to
asyncio.get_running_loop()forcesAsyncRedisSaverto be constructed in the context of a running event loop, despite not actually doing anything async in the constructor.I have found myself forced to do the following in order to bypass this, since i cannot easily perform this construction in async-land at the moment.