Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/361.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在python 3.4.1中同时执行两个不同的函数_Python_Python 3.x_Pandas_Multiprocessing - Fatal编程技术网

在python 3.4.1中同时执行两个不同的函数

在python 3.4.1中同时执行两个不同的函数,python,python-3.x,pandas,multiprocessing,Python,Python 3.x,Pandas,Multiprocessing,我已经看过很多关于这个话题的例子,但是我找不到任何适合我的答案。我需要你的帮助来了解这个问题的诀窍。 假设我有两个函数funA和funB。他们的论点完全相同。函数返回两个独立的输出,即一个对象。我想在没有GIL的情况下同时执行这些函数。 以下是我的代码示例: from multiprocessing import Process from queue import Queue q1 = Queue() q2 = Queue() res1 = Process(target=funA,args=(a

我已经看过很多关于这个话题的例子,但是我找不到任何适合我的答案。我需要你的帮助来了解这个问题的诀窍。 假设我有两个函数funA和funB。他们的论点完全相同。函数返回两个独立的输出,即一个对象。我想在没有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()
上述代码提供了以下回溯:

File "C:\Python34\lib\multiprocessing\reduction.py", line 59, in dump
 ForkingPickler(file, protocol).dump(obj)
_pickle.PicklingError: Can't pickle <class '_thread.lock'>: attribute lookup lock on _thread failed
我经历了以下几条线索,比如, ,


请帮帮我。提前感谢。

使用多处理。队列而不是队列。队列:

其给出错误:\u pickle.PicklingError:无法pickle:内置属性查找模块失败@John@sayak_SIBIA:请发布完整的可运行程序,因为我复制了您的代码并添加了必要的部分,并且在Python2和Python3上对我都有效。