我看过很多关于这个话题的例子,但是我找不到适合我的答案。我需要你的帮助来了解这个问题的诀窍。 假设有两个函数funA()和funB()。他们的论点完全相同。函数返回两个独立的输出,即pandas系列对象。我想在没有GIL的情况下同时执行这些功能。 下面是我的代码示例:
from multiprocessing import Process
from queue import Queue
q1 = Queue()
q2 = Queue()
res1 = Process(target=funA,args=(a,b,c,q1))
res1.start()
res2 = Process(target=funB,args=(a,b,c,q2))
res2.start()
res1.join()
res2.join()
result1 = q1.get()
result2 = q2.get()
上述代码给出了以下回溯:
^{pr2}$我已经通过了以下线程,比如http://sebastianraschka.com/Articles/2014_multiprocessing_intro.html, Concurrently run two functions that take parameters and return lists?,Make 2 functions run at the same time
请帮帮我。提前谢谢你。在
使用
multiprocessing.Queue
代替queue.Queue
:https://docs.python.org/2/library/multiprocessing.html#multiprocessing.Queue相关问题 更多 >
编程相关推荐