-
Notifications
You must be signed in to change notification settings - Fork 455
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
Bug Fix: Plugins Fail To Load on Python 3.8+ #505
Conversation
…wn processing which does not share memory between child processes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice find, let's hold off on merging this until we get CI set up again though, I'm interested to see whether py38/py39 tests pass on CI
@@ -55,7 +55,8 @@ def scan_files(self, *filenames: str, num_processors: Optional[int] = None) -> N | |||
if not num_processors: | |||
num_processors = mp.cpu_count() | |||
|
|||
with mp.Pool(processes=num_processors) as p: | |||
# Default to fork multiprocessing. Python 3.8+ defaults to spawn which doesn't share memory. | |||
with mp.get_context('fork').Pool(processes=num_processors) as p: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did find on https://docs.python.org/3/library/multiprocessing.html#contexts-and-start-methods
that it says fork
should not be used on macOS, and that it's not available on Windows
so it may be better to resolve this some other way
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated to pass the settings object to the child processes.
I think it may be better to use the approach with #482 -- essentially, initializing a new settings object per process, rather than sharing memory. It's been a while since I looked at it, but the This way, we'd be less dependent on OS level details since this library is used on multiple platforms. |
Problem
spawn
where before it wasfork
spawn
does not share any memory between the parent and child processes.Solution