成功解决ForkingPickler(file, protocol).dump(obj) TypeError: can't pickle Environment objects

成功解决ForkingPickler(file, protocol).dump(obj) TypeError: can't pickle Environment objects


解决问题

ForkingPickler(file, protocol).dump(obj)
TypeError: can't pickle Environment objects

解决思路

类型错误:无法pickle环境对象

解决方法(三种)

T1、将队列移动到self,而不是作为函数包和send的参数。

参考国外网友解释:TypeError: can't pickle _thread.lock objects

T2、multiprocessing.Manager().Queue() instead of multiprocessing.Queue
参考国外网友解释:multiprocessing.Pool - PicklingError: Can't pickle <type 'thread.lock'>: attribute lookup thread.lock failed

T3、寻求更好的办法ing

参考文章:
python2,socket多进程的错误pickle.PicklingError: Can't pickle
python3 PicklingError: Can't pickle attribute lookup on __main

(0)

相关推荐