Skip to content

Commit 70e6064

Browse files
authored
Update pytest_twisted.py
1 parent 37f0baf commit 70e6064

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

pytest_twisted.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -208,15 +208,12 @@ def init_twisted_greenlet():
208208

209209
def stop_twisted_greenlet():
210210
if _instances.gr_twisted:
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:
211+
try:
219212
_instances.reactor.stop()
213+
except error.ReactorNotRunning:
214+
# Sometimes the reactor is stopped before we get here. For example, this can
215+
# happen in response to a SIGINT in some cases.
216+
pass
220217
_instances.gr_twisted.switch()
221218

222219

0 commit comments

Comments
 (0)