成功解决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

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

 

 

 

 

解决思路

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

 

 

 

 

 

 

 

解决方法(三种)

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

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

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

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

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

T3、寻求更好的办法ing

 

 

 

 

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

上一篇:Environment.getExternalStorageDirectory()过时的替代方法


下一篇:使用postman工具做接口测试(七)——全局(Global)变量和环境(Environment)变量的使用