File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -360,14 +360,13 @@ def __init__(
360360 create_file_executor ,
361361 )
362362
363- if terminate_tasks_on_shutdown :
364- from executorlib .task_scheduler .file .queue_spawner import (
365- terminate_with_pysqa ,
366- )
363+ from executorlib .task_scheduler .file .queue_spawner import (
364+ get_terminate_function ,
365+ )
367366
368- terminate_function = terminate_with_pysqa
369- else :
370- terminate_function = None
367+ terminate_function = get_terminate_function (
368+ terminate_tasks_on_shutdown = terminate_tasks_on_shutdown
369+ )
371370
372371 super ().__init__ (
373372 executor = create_file_executor (
Original file line number Diff line number Diff line change @@ -166,14 +166,13 @@ def __init__(
166166 create_file_executor ,
167167 )
168168
169- if terminate_tasks_on_shutdown :
170- from executorlib .task_scheduler .file .queue_spawner import (
171- terminate_with_pysqa ,
172- )
169+ from executorlib .task_scheduler .file .queue_spawner import (
170+ get_terminate_function ,
171+ )
173172
174- terminate_function = terminate_with_pysqa
175- else :
176- terminate_function = None
173+ terminate_function = get_terminate_function (
174+ terminate_tasks_on_shutdown = terminate_tasks_on_shutdown
175+ )
177176
178177 super ().__init__ (
179178 executor = create_file_executor (
Original file line number Diff line number Diff line change @@ -138,3 +138,17 @@ def _pysqa_execute_command(
138138 return out .split ("\n " )
139139 else :
140140 return out
141+
142+
143+ def get_terminate_function (terminate_tasks_on_shutdown : bool ) -> Optional [callable ]:
144+ """
145+ Get the appropriate terminate function based on the shutdown configuration.
146+
147+ Args:
148+ terminate_tasks_on_shutdown (bool): Flag indicating whether to terminate tasks on shutdown.
149+
150+ Returns:
151+ Optional[callable]: The terminate function to use, or None if no termination is needed.
152+ """
153+ if terminate_tasks_on_shutdown :
154+ return terminate_with_pysqa
You can’t perform that action at this time.
0 commit comments