Skip to content

Commit

Permalink
Interrupt main thread on Exception in sub thread
Browse files Browse the repository at this point in the history
  • Loading branch information
NeoLegends committed Jan 9, 2025
1 parent bbbe0ae commit 440a89d
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions returnn/util/debug.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import sys
import signal

from returnn.util.basic import interrupt_main

try:
import thread
except ImportError:
Expand Down Expand Up @@ -182,6 +184,12 @@ def excepthook(exc_type, exc_obj, exc_tb):

sys.excepthook = excepthook

def threading_excepthook(args, /):
better_exchook(args["exc_type"], args["exc_value"], args["exc_traceback"], file=log.v1 or sys.stdout)
thread.interrupt_main()

threading.excepthook = threading_excepthook

from returnn.util.basic import to_bool

if os.environ.get("DEBUG_WARN_WITH_TRACEBACK") and to_bool(os.environ.get("DEBUG_WARN_WITH_TRACEBACK")):
Expand Down

0 comments on commit 440a89d

Please sign in to comment.