I'm trying to use the ProcessPoolExecutor method but it fails.
(我正在尝试使用ProcessPoolExecutor方法,但是它失败了。)
Here is an example(calculation of the big divider of two numbers) of a failed use. (这是一个使用失败的示例(计算两个数字的大除法)。)
I don't understand what the mistake is (我不明白这是什么错误)
def gcd(pair):
a, b = pair
low = min(a, b)
for i in range(low, 0, -1):
if a % i == 0 and b % i == 0:
return i
numbers = [(1963309, 2265973), (2030677, 3814172),
(1551645, 2229620), (2039045, 2020802)]
start = time()
pool = ProcessPoolExecutor(max_workers=2)
results = list(pool.map(gcd, numbers))
end = time()
print('Took %.3f seconds' % (end - start))
BrokenProcessPool: A process in the process pool was terminated abruptly while the future was running or pending.
(BrokenProcessPool:进程正在运行或挂起时,进程池中的进程突然终止。)
ask by Avraham translate from so 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…