MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / excepthook

Function excepthook

tools/python-3.11.9-amd64/Lib/threading.py:1289–1317  ·  view source on GitHub ↗

Handle uncaught Thread.run() exception.

(args, /)

Source from the content-addressed store, hash-verified

1287 return _ExceptHookArgs(*args)
1288
1289 def excepthook(args, /):
1290 """
1291 Handle uncaught Thread.run() exception.
1292 """
1293 if args.exc_type == SystemExit:
1294 # silently ignore SystemExit
1295 return
1296
1297 if _sys is not None and _sys.stderr is not None:
1298 stderr = _sys.stderr
1299 elif args.thread is not None:
1300 stderr = args.thread._stderr
1301 if stderr is None:
1302 # do nothing if sys.stderr is None and sys.stderr was None
1303 # when the thread was created
1304 return
1305 else:
1306 # do nothing if sys.stderr is None and args.thread is None
1307 return
1308
1309 if args.thread is not None:
1310 name = args.thread.name
1311 else:
1312 name = get_ident()
1313 print(f"Exception in thread {name}:",
1314 file=stderr, flush=True)
1315 _print_exception(args.exc_type, args.exc_value, args.exc_traceback,
1316 file=stderr)
1317 stderr.flush()
1318
1319
1320# Original value of threading.excepthook

Callers

nothing calls this directly

Calls 2

printFunction · 0.50
flushMethod · 0.45

Tested by

no test coverage detected