0
我需要一些幫助來解決這個問題。反覆產卵的過程相同
我遇到的問題是,進程1運行一個for循環裏面,數據收集和我需要產卵的過程來分析它。
這段代碼我只會創建每個進程一次,如何重複每個數據的循環過程2? TIA
from multiprocessing import Process, Queue
def data(q):
dosmth()
for i in range(5):
fetch_data()
q.put('data has been added')
def analysis(q):
msg = q.get()
print(msg)
process_data()
if __name__ == '__main__':
q = Queue()
processes = [Process(target=data, args=(q,)), Process(target=analysis, args=(q,))]
for p in processes:
p.start()
for p in processes:
p.join()