Ensure multithreading works#126
Merged
Merged
Conversation
Needed for python 3.14
ZedThree
reviewed
Jun 17, 2025
Comment on lines
+1632
to
+1638
| def _clean_for_mp(self): | ||
| new = object.__new__(BoutOutputs) | ||
| new.__dict__ = self.__dict__.copy() | ||
| new._file0 = None | ||
| new._root_file = None | ||
| new._workers = None | ||
| return new |
Member
There was a problem hiding this comment.
Does __getstate__ allow us to do this without having to call _clean_for_mp()? Then it might just be:
Suggested change
| def _clean_for_mp(self): | |
| new = object.__new__(BoutOutputs) | |
| new.__dict__ = self.__dict__.copy() | |
| new._file0 = None | |
| new._root_file = None | |
| new._workers = None | |
| return new | |
| def __getstate__(self): | |
| new = self.__dict__.copy() | |
| new.pop("_file0") | |
| new.pop("_root_file") | |
| new.pip("_workers") | |
| return new |
Contributor
Author
There was a problem hiding this comment.
The question is, do users expect to be able to pickle an object and still have _file0, _root_file and _workers?
How does BoutOptions behave if that is not set?
It is probably fine to allow BoutOptions to be pickled, and if someone in the future wants to unpickle it, and it is broken for their use case, we can add the fixes to __setstate__ ...
I will update the PR, thanks for the hints 👍
Member
There was a problem hiding this comment.
I'm not sure, but I agree we can cross that bridge when we come to it :)
This reverts commit bdec9a6.
This is needed so that multithreading works with python 3.14.
ZedThree
approved these changes
Jun 18, 2025
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.
Needed for python 3.14
Fixes #123