File tree Expand file tree Collapse file tree 1 file changed +10
-6
lines changed
Expand file tree Collapse file tree 1 file changed +10
-6
lines changed Original file line number Diff line number Diff line change @@ -133,6 +133,12 @@ def close_env():
133133 print ("Exception while closing env: " , e )
134134
135135
136+ def cleanup ():
137+ handle_onnx_export ()
138+ handle_model_save ()
139+ close_env ()
140+
141+
136142path_checkpoint = os .path .join (args .experiment_dir , args .experiment_name + "_checkpoints" )
137143abs_path_checkpoint = os .path .abspath (path_checkpoint )
138144
@@ -213,12 +219,10 @@ def func(progress_remaining: float) -> float:
213219 learn_arguments ["callback" ] = checkpoint_callback
214220 try :
215221 model .learn (** learn_arguments )
216- except KeyboardInterrupt :
222+ except ( KeyboardInterrupt , ConnectionError , ConnectionResetError ) :
217223 print (
218- """Training interrupted by user. Will save if --save_model_path was
224+ """Training interrupted by user or a ConnectionError . Will save if --save_model_path was
219225 used and/or export if --onnx_export_path was used."""
220226 )
221-
222- close_env ()
223- handle_onnx_export ()
224- handle_model_save ()
227+ finally :
228+ cleanup ()
You can’t perform that action at this time.
0 commit comments