Skip to content

Commit

Permalink
Update pool creation
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Fish committed Nov 6, 2024
1 parent 168c9a4 commit 2bc7744
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/sim_recon/recon.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,8 +381,11 @@ def run_single_reconstruction(
) -> None:

if multiprocessing_pool is None:
# `maxtasksperchild=1` is necessary to ensure the child process is cleaned
# up between tasks, as the cudasirecon process doesn't fully release memory
# afterwards
pool = multiprocessing.Pool(
processes=1 + int(parallel_process), # 2 processes max
processes=2 if parallel_process else 1, # 2 processes max
maxtasksperchild=1,
)
else:
Expand All @@ -393,9 +396,6 @@ def run_single_reconstruction(
logging_redirect = get_logging_redirect()
progress_wrapper = get_progress_wrapper()

# `maxtasksperchild=1` is necessary to ensure the child process is cleaned
# up between tasks, as the cudasirecon process doesn't fully release memory
# afterwards
with logging_redirect(), delete_directory_if_empty(processing_directory):
output_paths: tuple[Path, ...] | None = None
try:
Expand Down Expand Up @@ -564,7 +564,7 @@ def run_reconstructions(
# afterwards
with (
multiprocessing.Pool(
processes=1 + int(parallel_process), # 2 processes max
processes=2 if parallel_process else 1, # 2 processes max
maxtasksperchild=1,
) as pool,
logging_redirect(),
Expand Down

0 comments on commit 2bc7744

Please sign in to comment.