Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion pytest_twisted.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import itertools
import signal
import sys
import threading
import warnings

import decorator
Expand Down Expand Up @@ -200,7 +201,16 @@ def init_twisted_greenlet():
return

if not _instances.reactor.running:
if signal.getsignal(signal.SIGINT) == signal.default_int_handler:
if not isinstance(threading.current_thread(), threading._MainThread):
warnings.warn(
(
'Will not attempt to block Twisted signal configuration'
' since we are not running in the main thread. See'
' https://github.com/pytest-dev/pytest-twisted/issues/153.'
),
RuntimeWarning,
)
elif signal.getsignal(signal.SIGINT) == signal.default_int_handler:
signal.signal(
signal.SIGINT,
functools.partial(signal.default_int_handler),
Expand Down