Why am I getting an error about my class defining __slots__ when trying to pickle an object?

前端 未结 3 1154
星月不相逢
星月不相逢 2020-12-09 16:00

I\'m trying to pickle an object of a (new-style) class I defined. But I\'m getting the following error:

>>> with open(\'temp/connection.pickle\',\'         


        
3条回答
  •  旧时难觅i
    2020-12-09 16:17

    Perhaps an attribute of your instance is using __slots__

    For example, socket has __slots__ so it can't be pickled

    You need to identify which attribute is causing the error and write your own __getstate__ and __setstate__ to ignore that attribute

提交回复
热议问题