Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions task-sdk/tests/task_sdk/execution_time/test_supervisor.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,11 @@
log = logging.getLogger(__name__)
TI_ID = uuid7()

requires_posix_process = pytest.mark.skipif(
sys.platform == "win32",
reason="Exercises os.fork/os.posix_spawn/os.setpgid/os.killpg or signal.SIGKILL, which Windows lacks",
)


def lineno():
"""Returns the current line number in our program."""
Expand Down Expand Up @@ -824,6 +829,7 @@ def on_kill(self) -> None:
captured = capfd.readouterr()
assert "On kill hook called!" in captured.out

@requires_posix_process
def test_subprocess_sigkilled(self, client_with_ti_start):
main_pid = os.getpid()

Expand Down Expand Up @@ -1764,6 +1770,7 @@ def test_execution_timeout_not_enforced_once_task_is_over(self, mocker, terminal
mock_kill.assert_not_called()
proc.process_log.error.assert_not_called()

@requires_posix_process
@pytest.mark.parametrize(
("stops_on_sigterm", "expected_exit_code"),
[
Expand Down Expand Up @@ -1826,6 +1833,7 @@ def _on_term(signum, frame):
"loc": mocker.ANY,
} in captured_logs

@requires_posix_process
@pytest.mark.parametrize(
("signal_to_raise", "log_pattern", "level"),
(
Expand Down Expand Up @@ -1919,6 +1927,7 @@ def test_cleanup_sockets_after_delay(self, monkeypatch, mocker):
proc.selector.close.assert_called_once()
proc.stdin.close.assert_called_once()

@requires_posix_process
def test_task_runner_starts_in_new_process_group(self, client_with_ti_start):
"""Regression test for #65505: the task-runner child must be placed in
its own process group (PGID == its PID) so kill() can reach
Expand Down Expand Up @@ -1966,6 +1975,7 @@ def subprocess_main():
proc.kill(signal.SIGKILL, force=True)
proc.wait()

@requires_posix_process
def test_child_keeps_supervisor_process_group_by_default(self):
"""Subprocess types that don't opt in to new_process_group (DAG
processor, triggerer, callbacks) must keep the supervisor's process
Expand All @@ -1985,6 +1995,7 @@ def subprocess_main():
proc.kill(signal.SIGKILL, force=True)


@requires_posix_process
class TestWatchedSubprocessKill:
@pytest.fixture
def mock_process(self, mocker):
Expand Down Expand Up @@ -6021,6 +6032,7 @@ def test_start_rejects_non_importable_target_under_exec(self):
supervisor.WatchedSubprocess.start(target=lambda: None, use_exec=True)


@requires_posix_process
class TestStartUsesPosixSpawn:
"""use_exec=True goes through os.posix_spawn, never os.fork -- that's the whole point."""

Expand Down
Loading