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
()
| 15 | |
| 16 | # function to handle the experiment when unusual program ending occurs |
| 17 | def 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 | |
| 31 | def experiment_exception_hook(exc_type, value, tb): |