Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _parallel_map_fw_prop_step_loky(shared, values, task_args):
"""Loky-based implementation of :func:`parallel_map_fw_prop_step`."""
tlist = task_args[4]
pulses = task_args[2]
time_index = task_args[5]
n = len(values)
if time_index == 0:
# we only send the full task_args through IPC once, for the first time
# step. Subsequent time steps will reuse the data
shared.executors = [
LokyProcessPoolExecutor(
max_workers=1,
initializer=partial(
_pmfw_initializer, limit_thread_pool=USE_THREADPOOL_LIMITS
),
initargs=(
state_index,
task_args[0][state_index], # initial_state
task_args[1][state_index], # objective
task_args[2], # pulses
task_args[3], # pulses_mapping
task_args[4], # tlist
task_args[6][state_index], # propagator
),
)
for state_index in range(n)
]