bpo-37137: Fix test_asyncio: use TestCase.set_event_loop()#13779
Merged
vstinner merged 1 commit intopython:masterfrom Jun 3, 2019
vstinner:fix_test_asyncio
Merged
bpo-37137: Fix test_asyncio: use TestCase.set_event_loop()#13779vstinner merged 1 commit intopython:masterfrom vstinner:fix_test_asyncio
vstinner merged 1 commit intopython:masterfrom
vstinner:fix_test_asyncio
Conversation
Replace asyncio.set_event_loop() with TestCase.set_event_loop() of test_asyncio.utils: this method calls TestCase.close_loop() which waits until the executor completes, to avoid leaking dangling threads. Inherit from test_asyncio.utils.TestCase rather than unittest.TestCase.
asvetlov
approved these changes
Jun 3, 2019
Contributor
asvetlov
left a comment
There was a problem hiding this comment.
LGTM and thank you very much.
You are jedi for tests fighting!
vstinner
commented
Jun 3, 2019
| self.loop.close() | ||
| asyncio.set_event_loop(None) | ||
| super().tearDown() | ||
| self.set_event_loop(self.loop) |
Member
Author
There was a problem hiding this comment.
@asvetlov: I'm not sure about this change, but since tests still pass, it seems like the change is safe.
Member
Author
To be clear: I have no idea if this PR fix the issue, since I'm unable to reproduce https://bugs.python.org/issue37137
Well, I modified regrtest to make a test fail if there is "dangling thread", so I know this issue very well. I also reported https://bugs.python.org/issue34037 And I wrote TestCase.close_loop() and TestCase.set_event_loop() :-) |
DinoV
pushed a commit
to DinoV/cpython
that referenced
this pull request
Jan 14, 2020
…13779) Replace asyncio.set_event_loop() with TestCase.set_event_loop() of test_asyncio.utils: this method calls TestCase.close_loop() which waits until the executor completes, to avoid leaking dangling threads. Inherit from test_asyncio.utils.TestCase rather than unittest.TestCase.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Replace asyncio.set_event_loop() with TestCase.set_event_loop() of
test_asyncio.utils: this method calls TestCase.close_loop() which
waits until the executor completes, to avoid leaking dangling
threads.
https://bugs.python.org/issue37137