-
Notifications
You must be signed in to change notification settings - Fork 152
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
Use a loop proxy for better flexibility #235
Comments
This sounds interesting! As you mentioned in another comment the loop proxy could address many things related to loop teardown and orphaned tasks, because the context manager takes care of this when it exits. aioloop-proxy also includes an I played around with aioloop-proxy a bit. A large number of tests already work when replacing a couple of lines in
The failing tests were mostly related to subprocesses or setting a custom event loop or policy. Some special usage like the one in TestEventLoopStartedBeforeFixtures break, because the tasks in the test cases get attached to a different loop. Anyway, the new information made me wonder if the That's all I got for now :) |
From my point of view, the plugin should support two modes.
An overridable session-scope fixture exists that returns a root loop instance. An user can override this fixture in Each pytest node should have a loop proxy instance created from the proxy of the parent loop. |
Issue #91 is yet another problem that caused by the @asvetlov @Tinche Would it make sense to clean up open tasks before closing the current loop? This could serve as an intermediate solution until we integrate |
Good question! |
aioloop-proxy provide a proxy instance that is fully compatible with
asyncio.AbstractEventLoop
but allows to cooperate of multiple nested proxies at the same time.From pytest-asyncio point of view, a session-scope fixture can use a session-level loop proxy that can cooperate with module-level, class-level, and function-level ones providing good test isolation.
I have no proof of concept for pytest-asyncio yet, if somebody with deep pytest internals knowledge can help -- you are welcome!
The text was updated successfully, but these errors were encountered: