Python多处理挂起

Python多处理挂起,python,python-2.7,python-multithreading,Python,Python 2.7,Python Multithreading,我开始学习python中的多处理,但已经到了代码挂起的地步。它只是使用多线程简单地计算1000000个阶乘 import multiprocessing def part(n): ret = 1 n_max = n + 9999 while n <= n_max: ret *= n n += 1 print "Part "+ str(n-1) + " complete" return ret def buildli

我开始学习python中的多处理,但已经到了代码挂起的地步。它只是使用多线程简单地计算1000000个阶乘

import multiprocessing

def part(n):
    ret = 1
    n_max = n + 9999
    while n <= n_max:
        ret *= n
        n += 1
    print "Part "+ str(n-1) + " complete"
    return ret

def buildlist(n_max):
    n = 1
    L = []
    while n <= n_max:
        L.append(n)
        n += 10000
    return L

final = 1
ne = 0
if __name__ == '__main__':
    pool = multiprocessing.Pool()
    results = [pool.apply_async(part, (x,)) for x in buildlist(1000000)]
    for r in results:
        x = r.get()
        final *= x
        ne+= 1
        print ne
    print final
导入多处理
def部分(n):
ret=1
n_max=n+9999

而n程序工作正常---直到
打印最终版本。然后它花了大量的时间来打印这个数字,这是非常巨大的…

1000=8.2639316883×10^(5565708)
它一点也不简单。当然不简单,但代码很简单。我的意思是,在不进行多重处理的情况下进行阶乘运算的代码是相对简单的代码。是的,我让它运行大约15分钟后,它就完成了计算,请注意。