Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2acd812

Browse files
colesburyseehwan80
authored andcommitted
pythongh-128364: Fix flakytest_timeout test (pythongh-130724)
1 parent7373571 commit2acd812

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

‎Lib/test/test_concurrent_futures/test_wait.py‎

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

115115
deftest_timeout(self):
116116
short_timeout=0.050
117-
long_timeout=short_timeout*10
118117

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

121120
finished,pending=futures.wait(
122121
[CANCELLED_AND_NOTIFIED_FUTURE,
@@ -132,6 +131,9 @@ def test_timeout(self):
132131
finished)
133132
self.assertEqual(set([future]),pending)
134133

134+
# Set the event to allow the future to complete
135+
self.event.set()
136+
135137

136138
classThreadPoolWaitTests(ThreadPoolMixin,WaitTests,BaseTestCase):
137139

‎Lib/test/test_concurrent_futures/util.py‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
importmultiprocessing
22
importsys
3+
importthreading
34
importtime
45
importunittest
56
fromconcurrentimportfutures
@@ -46,18 +47,24 @@ def setUp(self):
4647

4748
self.t1=time.monotonic()
4849
ifhasattr(self,"ctx"):
50+
self.manager=multiprocessing.Manager()
51+
self.event=self.manager.Event()
4952
self.executor=self.executor_type(
5053
max_workers=self.worker_count,
5154
mp_context=self.get_context(),
5255
**self.executor_kwargs)
5356
else:
57+
self.event=threading.Event()
5458
self.executor=self.executor_type(
5559
max_workers=self.worker_count,
5660
**self.executor_kwargs)
5761

5862
deftearDown(self):
5963
self.executor.shutdown(wait=True)
6064
self.executor=None
65+
ifhasattr(self,"ctx"):
66+
self.manager.shutdown()
67+
self.manager=None
6168

6269
dt=time.monotonic()-self.t1
6370
ifsupport.verbose:

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp