Skip to content

Unclosed event loops warning from pytest-asyncio 0.17.0 on Windows #256

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

Closed
dvarrazzo opened this issue Jan 13, 2022 · 3 comments
Closed

Comments

@dvarrazzo
Copy link

Hello,

after updating to pytest-asyncio 0.17.0, and setting asyncio_mode=auto in the config, we are seeing asyncio tests failing because warnings are generated on Windows.

See this test run for the errors.

Is there anything wrong we are doing or is it a regression? This test configuration might be relevant.

Thank you very much

@asvetlov
Copy link
Contributor

Hey!
Could you please call asyncio.set_event_loop_policy() and uvloop.install() outside of the event_loop fixture.
@fixture(scope="session", autouse=True) could be a good place for such things.

dvarrazzo added a commit to psycopg/psycopg that referenced this issue Jan 13, 2022
Doing it in a fixture is too late: event_loop might have already been
called if the first test running is async, and it would fail on Windows.

This started to be needed after pytest-asyncio 0.17.0 was released.
See <pytest-dev/pytest-asyncio#256>.
@dvarrazzo
Copy link
Author

Almost! Setting up a session failed when the first test of the run is async (tests run order is randomized). The direction was right though.

The problem is solved my moving the initialisation code into pytest_sessionstart() instead.

Thank you very much!

@asvetlov
Copy link
Contributor

You are welcome!
Thank you for psycopg3 BTW.
This project makes aiopg obsolete, we can archive it and suggest using the well-supported upstream :)

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

No branches or pull requests

2 participants