Skip to content

Add a shared mixin for state that cannot be pickled - #4357

Open
rambleraptor wants to merge 1 commit into
apache:mainfrom
rambleraptor:transient-state-mixin
Open

rambleraptor wants to merge 1 commit into
apache:mainfrom
rambleraptor:transient-state-mixin

Conversation

@rambleraptor

Copy link
Copy Markdown
Collaborator

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?

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

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant