Skip to content

Windows: Psycopg cannot use the 'ProactorEventLoop' to run in async mode. #2741

@sdancer75

Description

@sdancer75

Under windows

psycopg.InterfaceError: Psycopg cannot use the 'ProactorEventLoop' to run in async mode. Please use a compatible event loop, for instance by running 'asyncio.run(..., loop_factory=asyncio.SelectorEventLoop(selectors.SelectSelector()))'

Windows defaults to ProactorEventLoop.

ProactorEventLoop is Windows' default, but doesn't work with psycopg (async PostgreSQL driver).

SelectorEventLoop works with psycopg on Windows

Solution

Under backend/api.py

if sys.platform == "win32":
    asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())

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