'multiprocessing + subprocess.check_out stuck at exception handling?
I'm trying to leverage multiprocessing to run a python script with multiple parameter values:
import subprocess
import multiprocessing
def func(n=1):
output = ''
try:
output = subprocess.check_output('python script.py -n {}'.format(n), shell=True)
except:
pass
return output
with multiprocessing.Pool(10) as pool:
pool.map(func, range(100))
Somehow Python will stuck but never finishes if one of the values in range(100) causes failure in func. I'm fine with those failures returning empty string. Given that the function is taking care of these cases with exception handling (do nothing), why multiprocessing still stuck there? Is there a way to force multiprocessing to skip those failures? Python version Python 3.6.13
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
