-
Notifications
You must be signed in to change notification settings - Fork 150
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
Deprecate event_loop
fixture overrides
#311
Comments
Regarding task cancellation etc. Also, Python 3.11 will likely have |
This would only work, if the user does not provide their own
This is really interesting! Let's park my proposal until we get to experiment with Linking the relevant issues for reference: |
@asvetlov If I understand correctly, |
There have been multiple feature requests for setting loop exception handlers (#205) and canceling tasks after the event loop has closed (#222, #309). I believe pytest-asyncio is not just about being able to write async tests, but about helping people to write good async code with pytest. That's why I think those requests are warranted.
All feature requests propose to add additional code to the
event_loop
fixture. However, a fair amount of pytest-asyncio users override the fixture, in order to control its scope. These overrides prevent us from extending theevent_loop
fixture for existing users. We could ask them to extend their override functions manually, but the fixture definition could become very length (see the code required for task and generator cleanup code in CPython)I propose to deprecate overrides of the
event_loop
fixture. This allows the pytest-asyncio developers to modify and extend theevent_loop
fixture behaviour with special setup code (e.g. loop exception handlers) and teardown code (e.g. task cleanup, raising warnings, etc.).The additional functionality of the
event_loop
fixture could be handled in a modular way. Pytest configuration options, for example, can serve as feature flags for new functionality, which would also improve our stability guarantees for new releases.The fixture scope would be controlled with the
asyncio_loop_scope = "session"
setting. Other features would add similar settings, e.g.asyncio_exceptions = "raise"
to address #205.Maybe this could be our way towards pytest-asyncio v1.0? I'd be happy to hear your feedback on this idea!
The text was updated successfully, but these errors were encountered: