fix: set nonzero exit code for SIGTERMException#21623
Merged
justusschock merged 6 commits intoLightning-AI:masterfrom Mar 30, 2026
Merged
fix: set nonzero exit code for SIGTERMException#21623justusschock merged 6 commits intoLightning-AI:masterfrom
justusschock merged 6 commits intoLightning-AI:masterfrom
Conversation
`SIGTERMException(SystemExit)` was raised without arguments, causing `SystemExit.code` to default to `None`, which Python converts to exit code 0. Scripts monitoring the training process exit code could not distinguish a SIGTERM termination from a successful exit. Override `__init__` to pass 143 (128 + SIGTERM signal number 15) to `SystemExit`, following the standard Unix convention. Fixes Lightning-AI#19916
deependujha
reviewed
Mar 30, 2026
deependujha
reviewed
Mar 30, 2026
deependujha
reviewed
Mar 30, 2026
deependujha
approved these changes
Mar 30, 2026
Codecov Report✅ All modified and coverable lines are covered by tests.
Additional details and impacted files@@ Coverage Diff @@
## master #21623 +/- ##
=========================================
- Coverage 87% 79% -8%
=========================================
Files 270 267 -3
Lines 23895 23839 -56
=========================================
- Hits 20675 18765 -1910
- Misses 3220 5074 +1854 |
justusschock
approved these changes
Mar 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Fixes #19916
SIGTERMExceptioninherits fromSystemExitbut was raised without arguments, soSystemExit.codedefaulted toNone— which Python converts to exit code 0. This made it impossible for wrapper scripts or job schedulers (e.g. SLURM) to distinguish a SIGTERM kill from a clean exit.The fix overrides
__init__to pass143(128 + signal 15) toSystemExit, following the standard Unix exit code convention for signal-terminated processes.Before submitting
📚 Documentation preview 📚: https://pytorch-lightning--21623.org.readthedocs.build/en/21623/