@@ -101,13 +101,13 @@ def _execute_task_without_cache(
101101 Returns:
102102 bool: True if the task was submitted successfully, False otherwise.
103103 """
104- try :
105- future_obj . set_result ( interface . send_and_receive_dict ( input_dict = task_dict ))
106- except Exception as thread_exception :
107- if isinstance (thread_exception , ExecutorlibSocketError ):
108- return False
109- else :
110- future_obj .set_exception (exception = thread_exception )
104+ output = interface . send_and_receive_dict ( input_dict = task_dict )
105+ if "result" in output :
106+ future_obj . set_result ( output [ "result" ])
107+ elif isinstance (output [ "error" ] , ExecutorlibSocketError ):
108+ return False
109+ else :
110+ future_obj .set_exception (exception = output [ "error" ] )
111111 return True
112112
113113
@@ -141,18 +141,17 @@ def _execute_task_with_cache(
141141 )
142142 file_name = os .path .abspath (os .path .join (cache_directory , task_key + "_o.h5" ))
143143 if file_name not in get_cache_files (cache_directory = cache_directory ):
144- try :
145- time_start = time . time ( )
146- result = interface . send_and_receive_dict ( input_dict = task_dict )
147- data_dict ["output" ] = result
144+ time_start = time . time ()
145+ output = interface . send_and_receive_dict ( input_dict = task_dict )
146+ if " result" in output :
147+ data_dict ["output" ] = output [ " result" ]
148148 data_dict ["runtime" ] = time .time () - time_start
149149 dump (file_name = file_name , data_dict = data_dict )
150- future_obj .set_result (result )
151- except Exception as thread_exception :
152- if isinstance (thread_exception , ExecutorlibSocketError ):
153- return False
154- else :
155- future_obj .set_exception (exception = thread_exception )
150+ future_obj .set_result (output ["result" ])
151+ elif isinstance (output ["error" ], ExecutorlibSocketError ):
152+ return False
153+ else :
154+ future_obj .set_exception (exception = output ["error" ])
156155 else :
157156 _ , _ , result = get_output (file_name = file_name )
158157 future_obj .set_result (result )
0 commit comments