Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 10 additions & 11 deletions cloudvolume/datasource/precomputed/image/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,16 @@ def parallel_execution(
):
global error_queue

error_queue = mp.Queue()
progress_queue = mp.Queue()
fs_lock = mp.Lock()
# Ensure processes do not accidentally inherit
# locks from forking and deadlock. Instead launch
# new interpreters.
ctx = mp.get_context("spawn")
error_queue = ctx.Queue()
progress_queue = ctx.Queue()
fs_lock = ctx.Lock()

if parallel is True:
parallel = mp.cpu_count()
parallel = ctx.cpu_count()
elif parallel <= 0:
raise ValueError(f"Parallel must be a positive number or boolean (True: all cpus). Got: {parallel}")

Expand Down Expand Up @@ -98,17 +102,12 @@ def cleanup(signum, frame):

try:
if progress:
proc = mp.Process(
target=progress_queue_listener,
proc = ctx.Process(
target=progress_queue_listener,
args=(progress_queue,total,desc)
)
proc.start()

# Ensure processes do not accidentally inherit
# locks from forking and deadlock. Instead launch
# new interpreters.
ctx = mp.get_context("spawn")

with concurrent.futures.ProcessPoolExecutor(
max_workers=parallel,
initializer=initialize_synchronization,
Expand Down