我正在尝试对 parselmouth PRAAT 函数应用多处理来提取多个函数。
import concurrent.futures
import time
with concurrent.futures.ProcessPoolExecutor(max_workers=8) as executor:
futures = [executor.submit(self.f1, ),executor.submit(self.f2, )]
for future in concurrent.futures.as_completed(futures):
data = future.result()
但是我得到了这个错误,这是多处理时不可拾取的对象的问题:
The above exception was the direct cause of the following exception:
TypeError Traceback (most recent call last)
<ipython-input-15-2dea24cd4bf1> in <module>
2 strr = time.time()
3 FeatureCalculateobj = FeatureCalculate(os.path.join(root,'P1_A2.wav'),async_flag=True)
4 print(time.time()-strr)
5
<ipython-input-13-f5b7e5b9fab3> in __init__(self, path, async_flag)
26
27 if async_flag:
self.main()
29 else:
30 self.str_pauses = self.extract_pauses_unasync()
<ipython-input-13-f5b7e5b9fab3> in main(self)
176 futures = [executor.submit(self.jitter_shimmer, )]
177 for future in concurrent.futures.as_completed(futures):
data = future.result()
179 print(data)
180
~/miniconda3/envs/via_3.7/lib/python3.7/concurrent/futures/_base.py in result(self, timeout)
raise CancelledError()
427 elif self._state == FINISHED:
return self.__get_result()
429
430 self._condition.wait(timeout)
~/miniconda3/envs/via_3.7/lib/python3.7/multiprocessing/queues.py in _feed(buffer, notempty, send_bytes, writelock, close, ignore_epipe, onerror, queue_sem)
234
235 # serialize the data before acquiring the lock
obj = _ForkingPickler.dumps(obj)
237 if wacquire is None:
238 send_bytes(obj)
~/miniconda3/envs/via_3.7/lib/python3.7/multiprocessing/reduction.py
in dumps(cls, obj, protocol)
49 def dumps(cls, obj, protocol=None):
50 buf = io.BytesIO()
cls(buf, protocol).dump(obj)
52 return buf.getbuffer()
53
TypeError: can't pickle parselmouth.Sound objects
cls(buf, protocol).dump(obj) TypeError: can't pickle parselmouth.Sound objects
虽然我没有将 parselmouth.Sound 对象作为参数传递给类方法,但我仍然收到此错误