From 46e3dd11b31753091d916af719e2dabfa1b38de0 Mon Sep 17 00:00:00 2001 From: adRn-s Date: Mon, 14 Oct 2024 14:25:00 +0200 Subject: [PATCH] assume I/O bound instead of CPU --- deeptools/mapReduce.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/deeptools/mapReduce.py b/deeptools/mapReduce.py index af0b1647c..b9f26a076 100644 --- a/deeptools/mapReduce.py +++ b/deeptools/mapReduce.py @@ -1,6 +1,6 @@ -import multiprocessing -from deeptoolsintervals import GTF +from concurrent.futures import ThreadPoolExecutor import random +from deeptoolsintervals import GTF debug = 0 @@ -138,10 +138,8 @@ def mapReduce(staticArgs, func, chromSize, "number of tasks".format(numberOfProcessors, len(TASKS)))) random.shuffle(TASKS) - pool = multiprocessing.Pool(numberOfProcessors) - res = pool.map_async(func, TASKS).get(9999999) - pool.close() - pool.join() + with ThreadPoolExecutor(max_workers=numberOfProcessors) as executor: + res = list(executor.map(func, TASKS)) else: res = list(map(func, TASKS))