2
我想同時處理一個函數三次,其中包含一個無限循環。Python多處理無限循環
我的代碼:
import multiprocessing
def worker(numbers):
while True:
print numbers
if __name__ == '__main__':
nums = ["1","2","3"]
for i in nums:
p = multiprocessing.Process(target=worker(i))
p.start()
的問題是不斷循環只能以「1」
1
1
1
1
1
1
1
您是否知道'target = worker(i)'___calls___包含無限循環的函數?你的代碼永遠不會到達'p.start()'。 –