-
Notifications
You must be signed in to change notification settings - Fork 160
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
Regression in 0.25.2 - Event loop is closed #1040
Comments
Thanks for the detailed report! |
I am also getting this error with my doctests. |
The error occurs already with v0.25.1 (in my case, when using it together with pytest-playwright). |
fwiw, another related regression in #1034 is that the shutdown can apparently also fail with CancelledError, which I guess should be suppressed? I'm not sure how/why, but we're seeing that. Might be something weird we are doing, but i think it is in general related to the fact that our own event-loop cleanup code conflicts with pytest-asyncio unconditionally cleaning things up without checking if it can/should. |
@medihack This has to be another issue. The problem I'm describing here is the direct cause of a change introduced in 0.25.2. Please try to check if your problem is not a user issue or an issue with pytest-playwright. If you get a reproducible test case working with 0.25.0 but not with 0.25.1 and 0.25.2, please open a separate issue as this is very likely unrelated and probably requires a different bug fix. |
The asyncio.Runner.close doesn't seem to handle CancelledErrors explicitly, neither in shutdown_asyncgens, nor in _cancel_all_tasks. It does forward any exceptions to the loop's default exception handler, though. Suppressing these errors seems like a good idea, until #205 is tackled. |
Pytest-asyncio v0.25.3 is available, which should address this issue. Thanks to @minrk for contributing the bug fix! |
If there is a user defined fixture which handles loop shutdown and closing the loop on its own, the plugin raises an error.
Expected behavior: If user code closes the event loop, pytest-asyncio should handle this transparently.
Actual behavior: pytest-asyncio raises RuntimeError: Event loop is closed.
Example working with 0.25.1, crashes with 0.25.2:
The text was updated successfully, but these errors were encountered: