Skip to content

Commit 72783ce

Browse files
committed
gh-128364: Fix flaky test_timeout test
1 parent ddc27f9 commit 72783ce

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

Lib/test/test_concurrent_futures/test_wait.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,9 @@ def test_all_completed(self):
114114

115115
def test_timeout(self):
116116
short_timeout = 0.050
117-
long_timeout = short_timeout * 10
117+
event = threading.Event()
118118

119-
future = self.executor.submit(time.sleep, long_timeout)
119+
future = self.executor.submit(event.wait)
120120

121121
finished, pending = futures.wait(
122122
[CANCELLED_AND_NOTIFIED_FUTURE,
@@ -126,6 +126,9 @@ def test_timeout(self):
126126
timeout=short_timeout,
127127
return_when=futures.ALL_COMPLETED)
128128

129+
event.set()
130+
futures.wait([future], return_when=futures.ALL_COMPLETED)
131+
129132
self.assertEqual(set([CANCELLED_AND_NOTIFIED_FUTURE,
130133
EXCEPTION_FUTURE,
131134
SUCCESSFUL_FUTURE]),

0 commit comments

Comments
 (0)