Skip to content

AsyncRedisSaver cannot be constructed outside an async context #179

@DanCardin

Description

@DanCardin

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()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions