mirror of
https://github.com/python/cpython.git
synced 2026-01-03 22:12:27 +00:00
[3.12] gh-130736: Fix asyncio test_shutdown_default_executor_timeout() (GH-130800) (#130826)
gh-130736: Fix asyncio test_shutdown_default_executor_timeout() (GH-130800)
Replace time.sleep() with threading.Event.
(cherry picked from commit 6c48ed7d62)
Co-authored-by: Victor Stinner <vstinner@python.org>
This commit is contained in:
parent
7ce5f15981
commit
a0ac4dbe88
1 changed files with 10 additions and 5 deletions
|
|
@ -232,20 +232,25 @@ def test_set_default_executor_error(self):
|
|||
self.assertIsNone(self.loop._default_executor)
|
||||
|
||||
def test_shutdown_default_executor_timeout(self):
|
||||
event = threading.Event()
|
||||
|
||||
class DummyExecutor(concurrent.futures.ThreadPoolExecutor):
|
||||
def shutdown(self, wait=True, *, cancel_futures=False):
|
||||
if wait:
|
||||
time.sleep(0.1)
|
||||
event.wait()
|
||||
|
||||
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))
|
||||
try:
|
||||
with self.assertWarnsRegex(RuntimeWarning,
|
||||
"The executor did not finishing joining"):
|
||||
self.loop.run_until_complete(
|
||||
self.loop.shutdown_default_executor(timeout=0.01))
|
||||
finally:
|
||||
event.set()
|
||||
|
||||
def test_call_soon(self):
|
||||
def cb():
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue