Repository navigation
Add a shared mixin for state that cannot be pickled - #4357
Open
rambleraptor wants to merge 1 commit into
Open
rambleraptor wants to merge 1 commit into
rambleraptor wants to merge 1 commit into
Conversation
Locks, thread-locals and caches have to be dropped when pickling and rebuilt afterwards. Each class has handled this with its own __getstate__ and __setstate__, and new locks keep landing without it. Add _TransientStateMixin and port FsspecFileIO and PyArrowFileIO to it.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Rationale for this change
I've commented on a number of PRs about how some of their changes will cause an object to no longer be pickle-able (https://docs.python.org/3/library/pickle.html) This can potentially be a breaking change for users, so we should avoid it when possible!
I don't love that we have to keep creating
__getstate__and__setstate__methods throughout the codebase. I've created a mixin that allows developers to define which variables cannot be pickled and then the mixin centralized the__getstate__and__setstate__changes for us.Are these changes tested?
I've added some tests and we're expecting the rest of the suite to work properly.
Are there any user-facing changes?