Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
471 views
in Technique[技术] by (71.8m points)

python - Python parallel.futures:ProcessPoolExecutor无法正常工作(Python concurrent.futures: ProcessPoolExecutor fail to work)

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...