@@ -57,7 +57,7 @@ def execute_tasks_h5(
5757 backend : Optional [str ] = None ,
5858 disable_dependencies : bool = False ,
5959 pmi_mode : Optional [str ] = None ,
60- cancel_futures_on_shutdown : bool = True ,
60+ cancel_futures_on_shutdown : bool = False ,
6161) -> None :
6262 """
6363 Execute tasks stored in a queue using HDF5 files.
@@ -89,7 +89,7 @@ def execute_tasks_h5(
8989 with contextlib .suppress (queue .Empty ):
9090 task_dict = future_queue .get_nowait ()
9191 if task_dict is not None and "shutdown" in task_dict and task_dict ["shutdown" ]:
92- if task_dict ["wait" ]:
92+ if task_dict ["wait" ] and not cancel_futures_on_shutdown :
9393 while len (memory_dict ) > 0 :
9494 memory_dict = {
9595 key : _check_task_output (
@@ -100,7 +100,7 @@ def execute_tasks_h5(
100100 for key , value in memory_dict .items ()
101101 if not value .done ()
102102 }
103- if task_dict ["cancel_futures" ] or cancel_futures_on_shutdown :
103+ if not task_dict ["cancel_futures" ] and not cancel_futures_on_shutdown :
104104 if (
105105 terminate_function is not None
106106 and terminate_function == terminate_subprocess
@@ -114,6 +114,19 @@ def execute_tasks_h5(
114114 config_directory = pysqa_config_directory ,
115115 backend = backend ,
116116 )
117+ else :
118+ memory_dict = {
119+ key : _check_task_output (
120+ task_key = key ,
121+ future_obj = value ,
122+ cache_directory = cache_dir_dict [key ],
123+ )
124+ for key , value in memory_dict .items ()
125+ if not value .done ()
126+ }
127+ for value in memory_dict .values ():
128+ if not value .done ():
129+ value .cancel ()
117130 future_queue .task_done ()
118131 future_queue .join ()
119132 break
0 commit comments