Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Appropriate asyncio.set_event_loop_policy to make scripts usable on Windows #3598

Open
rpahut opened this issue Nov 21, 2024 · 1 comment
Open

Comments

@rpahut
Copy link

rpahut commented Nov 21, 2024

Is your feature request related to a problem? Please describe.
Running nominatim-cli.py import on Windows eventually runs into an exception at psycopg.AsyncConnection.connect call:
Psycopg cannot use the 'ProactorEventLoop' to run in async mode. Please use a compatible event loop, for instance by setting 'asyncio.set_event_loop_policy(WindowsSelectorEventLoopPolicy())'

Describe the solution you'd like
The official solution to this exception is to set the event loop compatible with the OS some time before the async work:

asyncio.set_event_loop_policy(
    asyncio.WindowsSelectorEventLoopPolicy()
)

This removes the exception, and as far as I can tell there are no other fatal issues preventing the script from being used on Windows.

Describe alternatives you've considered
Simple ad-hoc modification to the nominatim-cli.py works, but set_event_loop_policy can be called almost anywhere before the connect and does not have to be a part of nominatim scripts.

@lonvia
Copy link
Member

lonvia commented Dec 12, 2024

We could add an appropriate line but I have no way to test if that actually works. Anybody interested to set up CI testing on a Windows machine?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants