Skip to content

Commit 191ac91

Browse files
committed
fix: directly exit with 0 after tests in Windows
1 parent 35e9e24 commit 191ac91

File tree

1 file changed

+8
-20
lines changed

1 file changed

+8
-20
lines changed

python/cocoindex/tests/conftest.py

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,18 @@
11
import pytest
22
import typing
33
import os
4-
import signal
4+
import sys
55

66

77
@pytest.fixture(scope="session", autouse=True)
8-
def _cocoindex_env_fixture() -> typing.Generator[None, None, None]:
8+
def _cocoindex_env_fixture(
9+
request: pytest.FixtureRequest,
10+
) -> typing.Generator[None, None, None]:
911
"""Shutdown the subprocess pool at exit."""
1012

1113
yield
1214

13-
try:
14-
print("Shutdown the subprocess pool at exit in hook.")
15-
import cocoindex.subprocess_exec
16-
17-
if os.name == "nt":
18-
original_sigint_handler = signal.getsignal(signal.SIGINT)
19-
try:
20-
signal.signal(signal.SIGINT, signal.SIG_IGN)
21-
cocoindex.subprocess_exec.shutdown_pool_at_exit()
22-
finally:
23-
try:
24-
signal.signal(signal.SIGINT, original_sigint_handler)
25-
except ValueError: # noqa: BLE001
26-
pass
27-
else:
28-
cocoindex.subprocess_exec.shutdown_pool_at_exit()
29-
except (ImportError, AttributeError): # noqa: BLE001
30-
pass
15+
if sys.platform.startswith("win"):
16+
# If any test failed, let pytest exit normally with nonzero code
17+
if request.session.testsfailed == 0:
18+
os._exit(0) # immediate success exit (skips atexit/teardown)

0 commit comments

Comments
 (0)