File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -208,7 +208,15 @@ def init_twisted_greenlet():
208
208
209
209
def stop_twisted_greenlet ():
210
210
if _instances .gr_twisted :
211
- _instances .reactor .stop ()
211
+ # check if the reactor is not stopped first to prevent calling stop() twice which results
212
+ # into an error, traceback printed and process hanging until it is killed with SIGKILL.
213
+ # This sometimes happens when the pytest process is sent a SIGINT signal.
214
+ # The reactor will stop itself as it register a SIGINT signal for itself and then it is
215
+ # stopped second time here.
216
+ # I don't understand when exactly is this happening but I am also observing here that
217
+ # reactor.running == True and reactor._stopped == True.
218
+ if not _instances .reactor ._stopped :
219
+ _instances .reactor .stop ()
212
220
_instances .gr_twisted .switch ()
213
221
214
222
You can’t perform that action at this time.
0 commit comments