python
runtime_error
official
true
SystemExit
ID: python/systemexit
80%Fix Rate
95%Confidence
0Evidence
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 3.x | active | — | — | — |
Root Cause
sys.exit() was called. The program is terminating normally with the specified exit code.
genericOfficial Documentation
https://docs.python.org/3/library/exceptions.htmlWorkarounds
-
90% success If you need to prevent exit, catch SystemExit specifically (not Exception)
except SystemExit as e: if e.code != 0: logging.warning('Exit with %s', e.code)
Dead Ends
Common approaches that don't work:
-
Catching SystemExit to prevent program exit
80% fail
Prevents intentional shutdown; may cause hung processes