File tree Expand file tree Collapse file tree 1 file changed +17
-8
lines changed Expand file tree Collapse file tree 1 file changed +17
-8
lines changed Original file line number Diff line number Diff line change @@ -48,8 +48,10 @@ def wait(self):
4848 self .timeout )
4949
5050 def _quit_loop_by_timeout (self ):
51- self ._loop .quit ()
52- self ._cleanup ()
51+ try :
52+ self ._cleanup ()
53+ finally :
54+ self ._loop .quit ()
5355
5456 def _cleanup (self ):
5557 if self ._timer is not None :
@@ -119,10 +121,12 @@ def _quit_loop_by_signal(self, *args):
119121 """
120122 quits the event loop and marks that we finished because of a signal.
121123 """
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 ()
126130
127131 def _cleanup (self ):
128132 super (SignalBlocker , self )._cleanup ()
@@ -171,8 +175,13 @@ def _signal_emitted(self, signal):
171175 """
172176 self ._signals [signal ] = True
173177 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 ()
176185
177186
178187class SignalTimeoutError (Exception ):
You can’t perform that action at this time.
0 commit comments