@@ -220,8 +220,11 @@ private void launchModelLoadOnProcess() throws IOException, InterruptedException
220220 throw new RuntimeException ();
221221 else if (task .status == TaskStatus .FAILED )
222222 throw new RuntimeException ();
223- else if (task .status == TaskStatus .CRASHED )
223+ else if (task .status == TaskStatus .CRASHED ) {
224+ this .runner .close ();
225+ runner = null ;
224226 throw new RuntimeException ();
227+ }
225228 }
226229
227230 /**
@@ -377,8 +380,11 @@ void runInterprocessing(List<Tensor<T>> inputTensors, List<Tensor<R>> outputTens
377380 throw new RuntimeException ();
378381 else if (task .status == TaskStatus .FAILED )
379382 throw new RuntimeException ();
380- else if (task .status == TaskStatus .CRASHED )
383+ else if (task .status == TaskStatus .CRASHED ) {
384+ this .runner .close ();
385+ runner = null ;
381386 throw new RuntimeException ();
387+ }
382388 for (int i = 0 ; i < outputTensors .size (); i ++) {
383389 String name = (String ) Types .decode (encOuts .get (i )).get (MEM_NAME_KEY );
384390 SharedMemoryArray shm = shmaOutputList .stream ()
@@ -511,8 +517,11 @@ public void closeModel() {
511517 throw new RuntimeException ();
512518 else if (task .status == TaskStatus .FAILED )
513519 throw new RuntimeException ();
514- else if (task .status == TaskStatus .CRASHED )
520+ else if (task .status == TaskStatus .CRASHED ) {
521+ this .runner .close ();
522+ runner = null ;
515523 throw new RuntimeException ();
524+ }
516525 this .runner .close ();
517526 this .runner = null ;
518527 return ;
0 commit comments