@@ -71,8 +71,8 @@ def __init__(self, cases, flaky_tests_mode):
71
71
self .total = len (cases )
72
72
self .failed = [ ]
73
73
self .crashed = 0
74
- self .terminate = False
75
74
self .lock = threading .Lock ()
75
+ self .shutdown_event = threading .Event ()
76
76
77
77
def PrintFailureHeader (self , test ):
78
78
if test .IsNegative ():
@@ -101,17 +101,19 @@ def Run(self, tasks):
101
101
for thread in threads :
102
102
# Use a timeout so that signals (ctrl-c) will be processed.
103
103
thread .join (timeout = 10000000 )
104
+ except (KeyboardInterrupt , SystemExit ), e :
105
+ self .shutdown_event .set ()
104
106
except Exception , e :
105
107
# If there's an exception we schedule an interruption for any
106
108
# remaining threads.
107
- self .terminate = True
109
+ self .shutdown_event . set ()
108
110
# ...and then reraise the exception to bail out
109
111
raise
110
112
self .Done ()
111
113
return not self .failed
112
114
113
115
def RunSingle (self , parallel , thread_id ):
114
- while not self .terminate :
116
+ while not self .shutdown_event . is_set () :
115
117
try :
116
118
test = self .parallel_queue .get_nowait ()
117
119
except Empty :
@@ -131,9 +133,8 @@ def RunSingle(self, parallel, thread_id):
131
133
output = case .Run ()
132
134
case .duration = (datetime .now () - start )
133
135
except IOError , e :
134
- assert self .terminate
135
136
return
136
- if self .terminate :
137
+ if self .shutdown_event . is_set () :
137
138
return
138
139
self .lock .acquire ()
139
140
if output .UnexpectedOutput ():
0 commit comments