Skip to content

Harden stress test kill on exit#267

Merged
amanusk merged 4 commits intomasterfrom
feat/stresser-clean
Mar 3, 2026
Merged

Harden stress test kill on exit#267
amanusk merged 4 commits intomasterfrom
feat/stresser-clean

Conversation

@amanusk
Copy link
Copy Markdown
Owner

@amanusk amanusk commented Mar 3, 2026

No description provided.

Copilot AI review requested due to automatic review settings March 3, 2026 02:39
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR hardens stress-process cleanup by isolating stress runs into their own process group and ensuring the process tree is terminated on exit/signals.

Changes:

  • Start stress subprocesses in a new session/process group (os.setsid) to improve kill reliability.
  • Extend shutdown handling (SIGTERM + atexit) to ensure stress processes are cleaned up when the app exits.
  • Rework kill_child_processes to attempt graceful termination (process group SIGTERM → per-proc terminate → SIGKILL) and add corresponding tests.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
s_tui/s_tui.py Adds SIGTERM handling, atexit cleanup, and launches stress with process-group isolation.
s_tui/helper_functions.py Reworks stress process-tree termination logic to be more robust and time-bounded.
tests/test_stress_controller.py Adds test ensuring stress start uses preexec_fn=os.setsid.
tests/test_helper_functions.py Adds tests for new process-group-first termination behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/test_helper_functions.py Outdated

import psutil
import pytest
from unittest.mock import MagicMock, patch, PropertyMock
Copy link

Copilot AI Mar 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PropertyMock is imported but not used in this test module. Please remove the unused import to keep the test file clean and avoid linting failures in stricter environments.

Suggested change
from unittest.mock import MagicMock, patch, PropertyMock
from unittest.mock import MagicMock, patch

Copilot uses AI. Check for mistakes.
Comment thread s_tui/helper_functions.py Outdated
Comment thread s_tui/s_tui.py
Comment on lines 179 to 186
stress_proc = subprocess.Popen(
stress_cmd, stdout=dev_null, stderr=dev_null
stress_cmd,
stdout=dev_null,
stderr=dev_null,
preexec_fn=os.setsid,
)
self.set_stress_process(psutil.Process(stress_proc.pid))
except OSError:
Copy link

Copilot AI Mar 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

subprocess.Popen(..., preexec_fn=os.setsid) can raise ValueError on platforms where preexec_fn isn't supported (and potentially subprocess.SubprocessError if the preexec_fn fails). Right now only OSError is caught, so start_stress may crash instead of logging and continuing. Consider catching ValueError as well (or on Python 3 using start_new_session=True instead of preexec_fn).

Copilot uses AI. Check for mistakes.
@amanusk amanusk merged commit 65851a3 into master Mar 3, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants