所以我试着通过做一点多处理来加速我的计算时间
我想用泳池工人。
在我的代码顶部我有
import Singal as s
import multiprocessing as mp
def wrapper(Channel):
Noise_Frequincies = []
for i in range(1,125):
Noise_Frequincies.append(60.0*float(i))
Noise_Frequincies.append(180.0)
filter1 = s.Noise_Reduction(Sample_Rate,Noise_Frequincies,Channel)
return filter1
到时候我用
Both_Channels = [Chan1, Chan2]
results = mp.Pool(2).map(wrapper,Both_Channels)
filter1 = results[0]
filter2 = results[1]
我得到以下错误
Exception in thread Thread-2:
Traceback (most recent call last):
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", line 808, in __bootstrap_inner
self.run()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", line 761, in run
self.__target(*self.__args, **self.__kwargs)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/multiprocessing/pool.py", line 342, in _handle_tasks
put(task)
PicklingError: Can't pickle <type 'function'>: attribute lookup __builtin__.function failed
Chan1和Chan2是我的信号阵列,我正试图从每个阵列中滤除一些噪声。 我对多处理还不熟悉,所以如果这是个愚蠢的错误,我很抱歉
我把这个问题标记为that Q/A的dup,总结一下:您不能pickle函数,当您将
wrapper()
传递给Pool().map()
时,您正在尝试这样做。要pickle函数,需要使用copy_reg,如example所示。不,他的问题是他试图pickle一个实例方法,这个方法与函数比较接近,因为两者都不能pickle。解决办法A也应该对你有用。
虽然我没有测试
高温高压
相关问题 更多 >
编程相关推荐