MCPcopy
hub / github.com/microsoft/qlib / experiment_exit_handler

Function experiment_exit_handler

qlib/workflow/utils.py:17–28  ·  view source on GitHub ↗

Method for handling the experiment when any unusual program ending occurs. The `atexit` handler should be put in the last, since, as long as the program ends, it will be called. Thus, if any exception or user interruption occurs beforehand, we should handle them first. Once `R` is e

()

Source from the content-addressed store, hash-verified

15
16# function to handle the experiment when unusual program ending occurs
17def experiment_exit_handler():
18 """
19 Method for handling the experiment when any unusual program ending occurs.
20 The `atexit` handler should be put in the last, since, as long as the program ends, it will be called.
21 Thus, if any exception or user interruption occurs beforehand, we should handle them first. Once `R` is
22 ended, another call of `R.end_exp` will not take effect.
23
24 Limitations:
25 - If pdb is used in your program, excepthook will not be triggered when it ends. The status will be finished
26 """
27 sys.excepthook = experiment_exception_hook # handle uncaught exception
28 atexit.register(R.end_exp, recorder_status=Recorder.STATUS_FI) # will not take effect if experiment ends
29
30
31def experiment_exception_hook(exc_type, value, tb):

Callers 1

registerMethod · 0.85

Calls 1

registerMethod · 0.45

Tested by

no test coverage detected