Skip to content

Commit 6b40400

Browse files
authored
Merge pull request #1905 from Bastian-Krause/bst/grpc-fork
tests: disable gRPC fork handlers to fix flaky fork() abort
2 parents 04bb2b6 + 2cf952d commit 6b40400

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

tests/conftest.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import logging
2+
import os
23
from signal import SIGTERM
34
import sys
45
import threading
@@ -13,6 +14,15 @@
1314

1415
psutil = pytest.importorskip("psutil")
1516

17+
# gRPC is only safe to fork() if gRPC objects are created in the child after the fork. The tests do
18+
# the opposite: the pytest process spawns labgrid-client via pexpect (forkpty) while gRPC is
19+
# already initialized in it, so gRPC's pthread_atfork handler can lose a race and abort the child
20+
# before it execs. Set GRPC_ENABLE_FORK_SUPPORT=0 to disable the handler; the spawned clients
21+
# fork+exec and never reuse an inherited channel, so it is not needed anyway.
22+
# See also https://github.com/grpc/grpc/blob/master/doc/fork_support.md
23+
os.environ.setdefault("GRPC_ENABLE_FORK_SUPPORT", "0")
24+
25+
1626
@pytest.fixture(scope="session")
1727
def curses_init():
1828
""" curses only reads the terminfo DB once on the first import, so make

0 commit comments

Comments
 (0)