File tree Expand file tree Collapse file tree 2 files changed +11
-2
lines changed
Lib/test/test_concurrent_futures Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -114,9 +114,8 @@ def test_all_completed(self):
114114
115115 def test_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
136138class ThreadPoolWaitTests (ThreadPoolMixin , WaitTests , BaseTestCase ):
137139
Original file line number Diff line number Diff line change 11import multiprocessing
22import sys
3+ import threading
34import time
45import unittest
56from concurrent import futures
@@ -46,18 +47,24 @@ def setUp(self):
4647
4748 self .t1 = time .monotonic ()
4849 if hasattr (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 def tearDown (self ):
5963 self .executor .shutdown (wait = True )
6064 self .executor = None
65+ if hasattr (self , "ctx" ):
66+ self .manager .shutdown ()
67+ self .manager = None
6168
6269 dt = time .monotonic () - self .t1
6370 if support .verbose :
You can’t perform that action at this time.
0 commit comments