Skip to content

Conversation

vstinner
Copy link
Member

@vstinner vstinner commented Jun 3, 2019

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

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.
Copy link
Contributor

@asvetlov asvetlov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM and thank you very much.
You are jedi for tests fighting!

self.loop.close()
asyncio.set_event_loop(None)
super().tearDown()
self.set_event_loop(self.loop)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@asvetlov: I'm not sure about this change, but since tests still pass, it seems like the change is safe.

@vstinner
Copy link
Member Author

vstinner commented Jun 3, 2019

LGTM and thank you very much.

To be clear: I have no idea if this PR fix the issue, since I'm unable to reproduce https://bugs.python.org/issue37137

You are jedi for tests fighting!

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() :-)

@vstinner vstinner merged commit 49a7e34 into python:master Jun 3, 2019
@vstinner vstinner deleted the fix_test_asyncio branch June 3, 2019 15:51
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
skip news tests Tests in the Lib/test dir
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants