gh-111358: Fix timeout behaviour in BaseEventLoop.shutdown_default_executor (#115622)

This commit is contained in:
Jamie Phan 2024-02-19 11:01:00 +11:00 committed by GitHub
parent edea0e7d99
commit 53d5e67804
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 29 additions and 9 deletions

View file

@ -231,6 +231,22 @@ class BaseEventLoopTests(test_utils.TestCase):
self.assertIsNone(self.loop._default_executor)
def test_shutdown_default_executor_timeout(self):
class DummyExecutor(concurrent.futures.ThreadPoolExecutor):
def shutdown(self, wait=True, *, cancel_futures=False):
if wait:
time.sleep(0.1)
self.loop._process_events = mock.Mock()
self.loop._write_to_self = mock.Mock()
executor = DummyExecutor()
self.loop.set_default_executor(executor)
with self.assertWarnsRegex(RuntimeWarning,
"The executor did not finishing joining"):
self.loop.run_until_complete(
self.loop.shutdown_default_executor(timeout=0.01))
def test_call_soon(self):
def cb():
pass