Windows 10双核计算机上的Python多处理冻结

时间:2020-04-30 17:53:14

标签: windows-10 python-multiprocessing freeze

我正在Windows 10上运行双核计算机。我开发了一个简单的程序来了解Python 2.7中的多处理。该程序以较小的值运行,但冻结为较大的值。我做错了什么?还是Python中存在错误?

import multiprocessing
from multiprocessing import freeze_support
import time

def basla(sayi):
    a =  time.time()
    for x in range(sayi):
      x = x + 1
    print(x)
    b = time.time()
    c = b-a
    print(c)

if __name__ == "__main__":
    freeze_support()
    a1=time.time()
    p1 = multiprocessing.Process(target=basla, args=(100000052, ))
    p2 = multiprocessing.Process(target=basla, args=(100000003, ))
    p1.start()
    p2.start()
    p1.join()
    p2.join()
    b1=time.time()
    c1=b1-a1
    print(c1)

0 个答案:

没有答案