@@ -23,15 +23,18 @@ def _wrapper(*args, **kwargs):
2323 returned_value = Queue ()
2424 kwargs = {** kwargs , 'returned_value' : returned_value }
2525
26+ json_path = None
27+
2628 try :
2729 process = Process (target = func , args = args , kwargs = kwargs )
2830 process .start ()
2931
30- path = kwargs . get ( 'path' , args [ 0 ])
32+ path = args [ 0 ] if args else kwargs [ 'path' ]
3133 json_path = f'{ TMP_DIR } /{ process .pid } .json'
3234 with open (json_path , 'w' , encoding = 'utf-8' ) as file :
3335 json .dump ({'path' : path }, file )
3436
37+ output = returned_value .get ()
3538 process .join ()
3639 except :
3740 # Terminate all relevant processes when something went wrong, e.g. Keyboard Interrupt
@@ -42,9 +45,10 @@ def _wrapper(*args, **kwargs):
4245 if psutil .pid_exists (process .pid ):
4346 process .terminate ()
4447 finally :
45- os .remove (json_path )
48+ if json_path is not None and os .path .exists (json_path ):
49+ os .remove (json_path )
4650
47- return returned_value . get ()
51+ return output
4852 return _wrapper
4953
5054def get_run_notebook_name (pid ):
@@ -369,6 +373,7 @@ def run_notebook(path, inputs=None, outputs=None, inputs_pos=1, replace_inputs_p
369373 exec_res ['notebook' ] = notebook
370374
371375 returned_value .put (exec_res ) # return for parent process
376+ return
372377
373378# Mask functions for database operations cells
374379def mask_inputs_reading (notebook , pos ):
0 commit comments