Skip to content

Commit

Permalink
interpret sigterm as sigint
Browse files Browse the repository at this point in the history
  • Loading branch information
leej3 committed May 22, 2024
1 parent c8de5eb commit 15d4c95
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tests/ignite/conftest.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import functools
import os
import shutil
import signal
import sys
import tempfile
import threading
import time
from pathlib import Path

Expand Down Expand Up @@ -34,6 +36,20 @@ def pytest_addoption(parser):
)


@pytest.fixture(scope="session", autouse=True)
def term_handler():
# This allows the pytest session to be terminated upon retries on CI. It may
# be worth using this fixture solely in that context. For a discussion on
# whether sigterm should be ignored see:
# https://github.com/pytest-dev/pytest/issues/5243
if threading.current_thread() is threading.main_thread() and hasattr(signal, "SIGTERM"):
orig = signal.signal(signal.SIGTERM, signal.getsignal(signal.SIGINT))
yield
signal.signal(signal.SIGTERM, orig)
else:
yield # Just pass through if SIGTERM isn't supported or we are not in the main thread


@pytest.fixture(
params=[
"cpu",
Expand Down

0 comments on commit 15d4c95

Please sign in to comment.