Skip to content

Comments

feat: Better signal logging#150

Merged
chipkent merged 5 commits intomainfrom
better_signal_logging
Feb 12, 2026
Merged

feat: Better signal logging#150
chipkent merged 5 commits intomainfrom
better_signal_logging

Conversation

@chipkent
Copy link
Member

This pull request significantly expands and improves the signal handler logging infrastructure in deephaven_mcp._logging. It now registers handlers for all catchable termination signals across Unix-like and Windows platforms, provides robust logging for signal-related shutdowns, and includes defensive error handling to ensure visibility even if logging fails. Comprehensive tests have been added to verify the correctness and resilience of the new signal handler logic.

Signal handler infrastructure improvements:

  • src/deephaven_mcp/_logging.py: Expanded signal handler registration to cover all catchable termination signals (including SIGTERM, SIGINT, SIGABRT, SIGHUP, SIGQUIT, SIGUSR1, SIGUSR2, SIGALRM, SIGPIPE, SIGBREAK), and clarified documentation to distinguish between catchable and non-catchable signals. [1] [2] [3]
  • src/deephaven_mcp/_logging.py: Refactored signal handler registration logic into _signal_handler and _register_signal functions, improving maintainability and error handling. Signal registration failures are now logged as debug messages, and the handler is defensive against logging failures, falling back to stderr as a last resort.

Testing and robustness:

  • tests/test__logging.py: Added and expanded tests to verify multiple signals are registered, defensive logging behavior, platform-specific signal handling, and graceful error handling for signal registration failures (OSError, RuntimeError, missing signals). [1] [2] [3]

These changes make the logging module much more robust and informative for debugging shutdowns and signal-related process events, especially in production and containerized environments.

…nals (#150)

This pull request significantly expands signal handler registration to cover all catchable termination signals across Unix/Linux/macOS and Windows platforms, improves error handling and defensive programming in signal handlers, and enhances test coverage for signal handler edge cases.

**Signal handler expansion:**

* Expanded `setup_signal_handler_logging()` to register handlers for all catchable termination signals instead
… code organization

Extracted `_signal_handler` and `_register_signal` as module-level functions from the nested scope within `setup_signal_handler_logging()`, enabling direct testing without complex mocking. Updated `_signal_handler` to use `types.FrameType | None` type hint instead of `object` for the frame parameter. Simplified test cases by removing unnecessary `importlib.reload()` calls and mock extraction logic, directly importing
Copy link
Contributor

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 pull request enhances the signal handler logging infrastructure in deephaven_mcp._logging by expanding coverage to all catchable termination signals across Unix-like and Windows platforms. The changes introduce robust defensive error handling, improve code maintainability through refactoring, and add comprehensive test coverage for various edge cases and failure scenarios.

Changes:

  • Expanded signal handler registration to cover all catchable termination signals (SIGTERM, SIGINT, SIGABRT, SIGHUP, SIGQUIT, SIGUSR1, SIGUSR2, SIGALRM, SIGPIPE, SIGBREAK)
  • Refactored signal handler logic into separate _signal_handler and _register_signal functions with defensive error handling
  • Added comprehensive tests for defensive logging, platform-specific signals, error handling, and edge cases

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.

File Description
src/deephaven_mcp/_logging.py Refactored signal handler registration into modular functions, expanded signal coverage, added defensive error handling with stderr fallback, and improved documentation
tests/test__logging.py Added 8 new test functions covering defensive logging failures, platform-specific signals, multiple error scenarios, and updated existing tests to verify multiple signal registration

…ad of direct function imports

Changed test imports from `from deephaven_mcp._logging import _signal_handler` to `import deephaven_mcp._logging as logging_mod` and updated function calls to use `logging_mod._signal_handler()`. This improves test isolation and follows the pattern established in the earlier signal handler refactoring.
Copy link
Contributor

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

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

Copy link
Contributor

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

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

chipkent and others added 2 commits February 12, 2026 13:09
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@chipkent chipkent merged commit cc34210 into main Feb 12, 2026
20 checks passed
@chipkent chipkent deleted the better_signal_logging branch February 12, 2026 20:13
@github-actions github-actions bot locked and limited conversation to collaborators Feb 12, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant