From 331afd10fff0c367e3826aa2dfc0e469e4ce0474 Mon Sep 17 00:00:00 2001 From: John Ragland Date: Wed, 15 Apr 2026 08:53:03 -0400 Subject: [PATCH] updated to spawn processes instead of fork --- src/pygenray/eigenrays.py | 2 +- src/pygenray/environment.py | 2 +- src/pygenray/launch_rays.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pygenray/eigenrays.py b/src/pygenray/eigenrays.py index 8b4f565..8b09f6b 100644 --- a/src/pygenray/eigenrays.py +++ b/src/pygenray/eigenrays.py @@ -127,7 +127,7 @@ def find_eigenrays( # map individual eigen ray finding to different workers if num_workers is None: num_workers = mp.cpu_count() - with mp.Pool(num_workers) as pool: + with mp.get_context('spawn').Pool(num_workers) as pool: results = list(tqdm(pool.imap(_find_single_eigenray, args_list), total=len(args_list), desc="Finding eigenrays")) # Filter out None results and add successful rays diff --git a/src/pygenray/environment.py b/src/pygenray/environment.py index 74033a6..dd6c011 100644 --- a/src/pygenray/environment.py +++ b/src/pygenray/environment.py @@ -347,7 +347,7 @@ def _process_ranges_chunked_parallel(c, r_chunks, n_cpus): # Run in parallel with progress bar all_results = [] - with mp.Pool(processes=n_cpus) as pool: + with mp.get_context('spawn').Pool(processes=n_cpus) as pool: for chunk_results in tqdm( pool.imap(_process_chunk_worker, args_list), total=len(r_chunks), diff --git a/src/pygenray/launch_rays.py b/src/pygenray/launch_rays.py index 131cef2..2de81e2 100644 --- a/src/pygenray/launch_rays.py +++ b/src/pygenray/launch_rays.py @@ -127,7 +127,7 @@ def shoot_rays( terminate_backwards=terminate_backwards ) - with mp.Pool(n_processes) as pool: + with mp.get_context('spawn').Pool(n_processes) as pool: rays_ls = list(tqdm(pool.imap(shoot_ray_part, y0s), total=len(y0s), desc="Computing ray fan")) ranges = np.linspace(source_range, receiver_range, num_range_save)