Commit 2747586a authored by Daniel Scheffler's avatar Daniel Scheffler
Browse files

Added 'maxtasksperchild=1' to Pool.


Signed-off-by: Daniel Scheffler's avatarDaniel Scheffler <danschef@gfz-potsdam.de>
parent e375d38a
Pipeline #8032 passed with stage
in 17 minutes and 38 seconds
......@@ -50,7 +50,7 @@ def MAP(func, args, CPUs=None, flatten_output=False):
CPUs = CPUs if CPUs <= CFG.CPUs else CFG.CPUs # treat CFG.CPUs as maximum number of CPUs
if CPUs and CPUs > 1 and len(args) > 1:
with Pool(CPUs) as pool:
with Pool(CPUs, maxtasksperchild=1) as pool:
results = pool.map(func, args) # always returns a list
else:
results = [func(argset) for argset in args] # generator does not always work properly here
......@@ -102,4 +102,5 @@ def imap_unordered(func, args, CPUs=None, flatten_output=False):
def is_mainprocess():
# type: () -> bool
"""Return True if the current process is the main process and False if it is a multiprocessing child process."""
print(current_process().name)
return current_process().name == 'MainProcess'
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment