-
-
Notifications
You must be signed in to change notification settings - Fork 31.4k
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
gh-121468: Ensure PDB cleans up event loop policies after using asyncio. #131388
Conversation
!buildbot iOS|Android |
🤖 New build scheduled with the buildbot fleet by @freakboy3742 for commit e8ed3a8 🤖 Results will be shown at: https://buildbot.python.org/all/#/grid?branch=refs%2Fpull%2F131388%2Fmerge The command will test the builders whose names match following regular expression: The builders matched are:
|
Hmm, I have some doubts to do this in |
True - but AFAICT, it should be a benign (and fast) cleanup; and it guarantees that any PDB test that triggers asyncio activity will guarantee that it will be cleaned up automatically, rather than requiring test developers to remember that asyncio cleanup is needed on a per-test basis. This is especially significant for iOS and Android, because they often end up as the "canary" identifying issues with sequential test execution. There's nothing iOS- or Android-speciifc about this test or test failure, but the iOS and Android buildbots are the only ones that reveal the problem because they're the only test configurations that actually run the tests sequentially. Anything we can do to systematically prevent this class of failure in the future is a win for me because I don't have to chase down buildbot failures that aren't actually caused by iOS- or Android-specific issues. |
The reason it feels weird to me is that this piece of code does not belong there. I think a better place would be |
Agreed - that makes more sense. I've made that modification. |
!buildbot iOS|Android |
🤖 New build scheduled with the buildbot fleet by @freakboy3742 for commit 6c794e0 🤖 Results will be shown at: https://buildbot.python.org/all/#/grid?branch=refs%2Fpull%2F131388%2Fmerge The command will test the builders whose names match following regular expression: The builders matched are:
|
!buildbot iOS |
🤖 New build scheduled with the buildbot fleet by @freakboy3742 for commit 584aa2b 🤖 Results will be shown at: https://buildbot.python.org/all/#/grid?branch=refs%2Fpull%2F131388%2Fmerge The command will test the builders whose names match following regular expression: The builders matched are:
|
So we are doing a double insurance here. |
@gaogaotiantian Following discussion with @graingert on Discord, I've modified this to use a two-prong approach:
@graingert mentioned he has an in-progress PR to fail if the |
… asyncio. (python#131388) Adds teardown logic, plus a change to asyncio.run usage, to avoid warnings when running the test suite single process.
#124367 added a PDB test that interacts with asyncio. Under some conditions, this can lead to a warning during test execution because the PDB test "alters the execution environment" by setting an event loop policy:
This problem only manifests if you run the tests suite sequentially, or if an asyncio test is performed in the same process as the
test_pdb
test. iOS and Android tests are always run sequentially, so those platforms are hitting this problem reliably.This fix ensures that
test_pdb
cleans up the event policy at the end of each test. The approach I've taken seems consistent with other "end of test cleanup" methods intest_asyncio
.