File tree Expand file tree Collapse file tree 2 files changed +10
-3
lines changed
Lib/test/test_concurrent_futures Expand file tree Collapse file tree 2 files changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -114,9 +114,9 @@ def test_all_completed(self):
114114
115115 def test_timeout (self ):
116116 short_timeout = 0.050
117- event = threading . Event ()
117+ self . event . clear ()
118118
119- future = self .executor .submit (event .wait )
119+ future = self .executor .submit (self . event .wait )
120120
121121 finished , pending = futures .wait (
122122 [CANCELLED_AND_NOTIFIED_FUTURE ,
@@ -126,7 +126,7 @@ def test_timeout(self):
126126 timeout = short_timeout ,
127127 return_when = futures .ALL_COMPLETED )
128128
129- event .set ()
129+ self . event .set ()
130130 futures .wait ([future ], return_when = futures .ALL_COMPLETED )
131131
132132 self .assertEqual (set ([CANCELLED_AND_NOTIFIED_FUTURE ,
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