Skip to content

Commit 6f7c883

Browse files
authored
Merge branch 'main' into hypothesis
2 parents 0170b4a + 8dc50e9 commit 6f7c883

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

pytest_twisted.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import itertools
44
import signal
55
import sys
6+
import threading
67
import warnings
78

89
import decorator
@@ -200,7 +201,16 @@ def init_twisted_greenlet():
200201
return
201202

202203
if not _instances.reactor.running:
203-
if signal.getsignal(signal.SIGINT) == signal.default_int_handler:
204+
if not isinstance(threading.current_thread(), threading._MainThread):
205+
warnings.warn(
206+
(
207+
'Will not attempt to block Twisted signal configuration'
208+
' since we are not running in the main thread. See'
209+
' https://github.com/pytest-dev/pytest-twisted/issues/153.'
210+
),
211+
RuntimeWarning,
212+
)
213+
elif signal.getsignal(signal.SIGINT) == signal.default_int_handler:
204214
signal.signal(
205215
signal.SIGINT,
206216
functools.partial(signal.default_int_handler),

0 commit comments

Comments
 (0)