问题描述
我是MPIPoolExecutor的新手,需要在我的项目中使用三个参数x,y和z多次计算一个耗时的函数,其中z遍历大型NumPy数组Z。此函数返回一个列表:>
my_output = [self.my_function(x,y,z) for z in self.Z]
因为这部分程序太慢,所以我试图使用MPIPoolExecutor来加快速度。 执行器在 init 函数中初始化:
self.executor = MPIPoolExecutor(max_workers=3)
然后在我编写的方法中:
arg_2 = list(repeat(x,len(self.Z)))
arg_3 = list(repeat(y,len(self.Z)))
prob_pool = self.executor.map(self.my_function,self.Z,arg_2,arg_3)
prob_pool_list = list(prob_pool)
不幸的是,我收到了我无法理解的错误:
File ".../lib/python3.6/site-packages/mpi4py/futures/pool.py",line 207,in result_iterator
yield futures.pop().result()
File "/usr/lib/python3.6/concurrent/futures/_base.py",line 432,in result
return self.__get_result()
File "/usr/lib/python3.6/concurrent/futures/_base.py",line 384,in __get_result
raise self._exception
TypeError: can't pickle _thread.lock objects
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)