File tree 2 files changed +11
-2
lines changed
Lib/test/test_concurrent_futures
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):
114
114
115
115
def test_timeout (self ):
116
116
short_timeout = 0.050
117
- long_timeout = short_timeout * 10
118
117
119
- future = self .executor .submit (time . sleep , long_timeout )
118
+ future = self .executor .submit (self . event . wait )
120
119
121
120
finished , pending = futures .wait (
122
121
[CANCELLED_AND_NOTIFIED_FUTURE ,
@@ -132,6 +131,9 @@ def test_timeout(self):
132
131
finished )
133
132
self .assertEqual (set ([future ]), pending )
134
133
134
+ # Set the event to allow the future to complete
135
+ self .event .set ()
136
+
135
137
136
138
class ThreadPoolWaitTests (ThreadPoolMixin , WaitTests , BaseTestCase ):
137
139
Original file line number Diff line number Diff line change 1
1
import multiprocessing
2
2
import sys
3
+ import threading
3
4
import time
4
5
import unittest
5
6
from concurrent import futures
@@ -46,18 +47,24 @@ def setUp(self):
46
47
47
48
self .t1 = time .monotonic ()
48
49
if hasattr (self , "ctx" ):
50
+ self .manager = multiprocessing .Manager ()
51
+ self .event = self .manager .Event ()
49
52
self .executor = self .executor_type (
50
53
max_workers = self .worker_count ,
51
54
mp_context = self .get_context (),
52
55
** self .executor_kwargs )
53
56
else :
57
+ self .event = threading .Event ()
54
58
self .executor = self .executor_type (
55
59
max_workers = self .worker_count ,
56
60
** self .executor_kwargs )
57
61
58
62
def tearDown (self ):
59
63
self .executor .shutdown (wait = True )
60
64
self .executor = None
65
+ if hasattr (self , "ctx" ):
66
+ self .manager .shutdown ()
67
+ self .manager = None
61
68
62
69
dt = time .monotonic () - self .t1
63
70
if support .verbose :
You can’t perform that action at this time.
0 commit comments