Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

__shared_instance_cache__ = False 时缓存类的实例和实例中的方法无法被 pickle #6

Open
2018-11-27 opened this issue Apr 1, 2024 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@2018-11-27
Copy link
Member

2018-11-27 commented Apr 1, 2024

pickle 时会引发异常,如:

TypeError: cannot pickle '_thread.lock' object
@2018-11-27
Copy link
Member Author

当将 __shared_instance_cache__ 设为 True 时,其实例可以正确进行对象序列化和反序列化。但实例的方法在反序列化引发如下异常:

TypeError: MethodCaller.__new__() missing 4 required positional arguments: 'cls_', 'sget', 'name', and 'method'

@2018-11-27
Copy link
Member Author

问题已定位到 MethodCaller.__init__ 中的行 self.__sget = sget,后续将进一步排查。

当前可通过将需要 pickle 的方法加入到 __not_cache__ 列表中来规避这个问题。

@2018-11-27 2018-11-27 self-assigned this Apr 1, 2024
@2018-11-27 2018-11-27 added the bug Something isn't working label Apr 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant