Skip to content

Commit

Permalink
executors/multi_exec_async.py: init_and_compute as a method
Browse files Browse the repository at this point in the history
  • Loading branch information
paugier committed Feb 16, 2024
1 parent d886b27 commit 23c36b4
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions src/fluidimage/executors/multi_exec_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,28 +274,28 @@ def start_multiprocess_series(self):

self.wait_for_all_processes()

def launch_process(self, topology, ind_process):
"""Launch one process"""
def init_and_compute(self, topology_this_process, log_path, child_conn):
"""Create an executor and start it in a process"""
executor = ExecutorAsyncForMulti(
topology_this_process,
self.path_dir_result,
sleep_time=self.sleep_time,
log_path=log_path,
logging_level=self.logging_level,
)
executor.t_start = self.t_start
executor.compute()

def init_and_compute(topology_this_process, log_path, child_conn):
"""Create an executor and start it in a process"""
executor = ExecutorAsyncForMulti(
topology_this_process,
self.path_dir_result,
sleep_time=self.sleep_time,
log_path=log_path,
logging_level=self.logging_level,
)
executor.t_start = self.t_start
executor.compute()
# send the results
if hasattr(topology_this_process, "results"):
results = topology_this_process.results
else:
results = None

# send the results
if hasattr(topology_this_process, "results"):
results = topology_this_process.results
else:
results = None
child_conn.send(results)

child_conn.send(results)
def launch_process(self, topology, ind_process):
"""Launch one process"""

log_path = Path(
str(self._log_path).split(".txt")[0] + f"_multi{ind_process:03}.txt"
Expand All @@ -306,7 +306,7 @@ def init_and_compute(topology_this_process, log_path, child_conn):
parent_conn, child_conn = Pipe()

process = Process(
target=init_and_compute, args=(topology, log_path, child_conn)
target=self.init_and_compute, args=(topology, log_path, child_conn)
)
process.connection = parent_conn
process.daemon = True
Expand Down

0 comments on commit 23c36b4

Please sign in to comment.