Skip to content

Commit

Permalink
Add a top-level exception handler (#947)
Browse files Browse the repository at this point in the history
As the comment says: let's see if adding a top-level handler (that then
re-raises) and catching BaseException will give us more info as to
what's sometimes causing Tron to exit.

I've also added the usual base exception (Exception) just to be
extra-safe

(h/t to krall for the idea)
  • Loading branch information
nemacysts authored Mar 27, 2024
1 parent 26069d7 commit e111b6e
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion bin/trond
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env python
""" Start the Tron server daemon."""
import argparse
import faulthandler
import logging
import os
import traceback
Expand Down Expand Up @@ -174,4 +175,21 @@ def main():


if __name__ == "__main__":
main()
# print tracebacks on signals/faults
# NOTE: you likely want to read https://docs.python.org/3/library/faulthandler.html
# as these tracebacks will look slightly different
faulthandler.enable()

try:
main()
# this is a little weird, but every now and then we're seeing a mysterious tron exit
# that doesn't seem to correspond with anything else - let's catch BaseException
# (and therefore SystemExit) in case anything is calling sys.exit() since there's no
# traceback when we see this
except (
BaseException,
# technically, we really only need to catch BaseException - but let's be extra-paranoid
Exception,
):
traceback.print_exc()
raise

0 comments on commit e111b6e

Please sign in to comment.