-
-
Notifications
You must be signed in to change notification settings - Fork 31.8k
[WIP/RFC] multiprocessing: proxy: keep _manager after forking #17333
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
Draft
blueyed
wants to merge
1
commit into
python:main
Choose a base branch
from
blueyed:mp-manager
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
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
Fixes iterating over dicts: import multiprocessing as mp def run(d): for k in d: print(k) manager = mp.Manager() d = manager.dict({1: 2, 3: 4}) process = mp.Process(target=run, args=(d,)) process.start() process.join() With this fix: _callmethod __iter__ #PROXY (('__next__', 'send', 'throw', 'close'), Token(typeid='Iterator', address='/tmp/pymp-wfn3r3nd/listener-ze4ow_dl', id='7f12414ca130')) _callmethod __next__ #RETURN 1 1 _callmethod __next__ #RETURN 3 3 _callmethod __next__ #ERROR Without: _callmethod __iter__ #PROXY (('__next__', 'send', 'throw', 'close'), Token(typeid='Iterator', address='/tmp/pymp-uppzhf9p/listener-mvmwwxma', id='7f5b7b42da90')) Process Process-2: Traceback (most recent call last): File "…/pyenv/3.8.0/lib/python3.8/multiprocessing/process.py", line 313, in _bootstrap self.run() File "…/pyenv/3.8.0/lib/python3.8/multiprocessing/process.py", line 108, in run self._target(*self._args, **self._kwargs) File "t-mp.py", line 5, in run for k in d: File "<string>", line 2, in __iter__ File "…/pyenv/3.8.0/lib/python3.8/multiprocessing/managers.py", line 842, in _callmethod proxytype = self._manager._registry[token.typeid][-1] AttributeError: 'NoneType' object has no attribute '_registry' The line is from when multiprocessing was added in e711caf, so I am probably missing something here? This PR is meant to get tests run with it, and of course for any feedback already.
blueyed
added a commit
to blueyed/pytest
that referenced
this pull request
Nov 22, 2019
Use `dict.keys()` to work around `__iter__` not working with a multiprocessing DictProxy. Ref: python/cpython#17333 Fixes pytest-dev#6254. Ref: kevlened/pytest-parallel#36
blueyed
added a commit
to blueyed/pytest
that referenced
this pull request
Nov 22, 2019
Use `dict.keys()` to work around `__iter__` not working with a multiprocessing DictProxy. Ref: python/cpython#17333 Fixes pytest-dev#6254. Ref: kevlened/pytest-parallel#36 (cherry picked from commit 1f736a6)
/cc @benjaminp |
vinaycalastry
pushed a commit
to vinaycalastry/pytest
that referenced
this pull request
Dec 11, 2019
Use `dict.keys()` to work around `__iter__` not working with a multiprocessing DictProxy. Ref: python/cpython#17333 Fixes pytest-dev#6254. Ref: kevlened/pytest-parallel#36
@benjaminp Do you know why The above-referenced issue prevents dictionary syntax like However, |
The following commit authors need to sign the Contributor License Agreement: |
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.
Fixes iterating over dicts:
With this fix:
Without:
The line is from when multiprocessing was added in e711caf, so I am
probably missing something here? This PR is meant to get tests run with
it, and of course for any feedback already.