File tree 1 file changed +17
-8
lines changed
1 file changed +17
-8
lines changed Original file line number Diff line number Diff line change @@ -48,8 +48,10 @@ def wait(self):
48
48
self .timeout )
49
49
50
50
def _quit_loop_by_timeout (self ):
51
- self ._loop .quit ()
52
- self ._cleanup ()
51
+ try :
52
+ self ._cleanup ()
53
+ finally :
54
+ self ._loop .quit ()
53
55
54
56
def _cleanup (self ):
55
57
if self ._timer is not None :
@@ -119,10 +121,12 @@ def _quit_loop_by_signal(self, *args):
119
121
"""
120
122
quits the event loop and marks that we finished because of a signal.
121
123
"""
122
- self .signal_triggered = True
123
- self .args = list (args )
124
- self ._loop .quit ()
125
- self ._cleanup ()
124
+ try :
125
+ self .signal_triggered = True
126
+ self .args = list (args )
127
+ self ._cleanup ()
128
+ finally :
129
+ self ._loop .quit ()
126
130
127
131
def _cleanup (self ):
128
132
super (SignalBlocker , self )._cleanup ()
@@ -171,8 +175,13 @@ def _signal_emitted(self, signal):
171
175
"""
172
176
self ._signals [signal ] = True
173
177
if all (self ._signals .values ()):
174
- self .signal_triggered = True
175
- self ._loop .quit ()
178
+ try :
179
+ # of course setting signal_triggered can't raise, but
180
+ # leave this try/finally here as a reminder for future
181
+ # additions
182
+ self .signal_triggered = True
183
+ finally :
184
+ self ._loop .quit ()
176
185
177
186
178
187
class SignalTimeoutError (Exception ):
You can’t perform that action at this time.
0 commit comments