Skip to content

Commit 02111fb

Browse files
committed
use thread method if not main thread
fixes pytest-dev#8
1 parent 5c4dde0 commit 02111fb

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

pytest_timeout.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import traceback
1717
from collections import namedtuple
1818
from distutils.version import LooseVersion
19-
from threading import current_thread
19+
from threading import current_thread, main_thread
2020
from _pytest.config import ExitCode
2121
from _pytest.outcomes import Failed
2222

@@ -198,6 +198,10 @@ def timeout_setup(item):
198198
params = get_params(item)
199199
if params.timeout is None or params.timeout <= 0:
200200
return
201+
202+
if params.method == "signal" and not (current_thread() is main_thread()):
203+
params.method = "thread"
204+
201205
if params.method == "signal":
202206

203207
def handler(signum, frame):

0 commit comments

Comments
 (0)