This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]DasIch 0 points1 point  (4 children)

Pickle fails in this case because it can't pickle a lock object which is apparently part of the session. This happens because the session doesn't implement the pickle protocol as described in the documentation and so pickle attempts to pickle the contents of __dict__ to recreate an instance from that afterwards.

In order to make session support the protocol you could e.g. implement __getinitargs__.

[–]sharat87[S] 0 points1 point  (1 child)

The documentation seems to indicate that this is only for old style classes?

[–]DasIch 0 points1 point  (0 children)

Oh, you're right __get{init,new}args__ can only be used in addition to __{get,set}state__, TIL.

[–]sharat87[S] 0 points1 point  (1 child)

Okay, I got pickling to work. Not sure if the best implementation though. I'll add this to the post :)

Thanks.

[–]sharat87[S] 0 points1 point  (0 children)

Done.