self._manager is None when proxy gets passed between processes and causes AttributeError
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 3/5
- Temps estimé
- 1-2 jours
- Accessibilité débutants
- 25/100
Piste de recherche
Reproduisez l’échec avec l’exemple minimal test.py, puis examinez Lib/multiprocessing/managers.py autour de BaseProxy._callmethod ainsi que la PR liée gh-99598. C’est terminé lorsqu’un proxy transmis à un autre processus peut appeler make_child sans l’AttributeError et que la régression est couverte par un test.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
Bug report
When a proxy derived from multiprocessing.managers.BaseProxy is passed between processes, the self._manager attribute becomes None. self._manager is however accessed to retrieve its _registry attribute, which contain the method_to_typeid map recorded into the manager viaBaseManager.register(), causing an AttributeError. The solution is to decouple the role of the manager from the role of the registry and propagate the registry separately. I'll submit a pull request to fix this.
Minimal failing example
test.py
from multiprocessing import Process
from multiprocessing.managers import BaseProxy, BaseManager
class Parent(object):
def __init__(self, *args, **kwargs):
pass
def make_child(self):
return Parent()
class MyManager(BaseManager):
pass
def child_generator(parent):
parent.make_child()
if __name__ == "__main__":
MyManager.register('Parent', callable=Parent,
method_to_typeid={'make_child': 'Parent'})
with MyManager() as manager:
parent = manager.Parent()
process = Process(target=child_generator, args=(parent, ))
process.start()
process.join()
Output
❯ python3 test.py
Process Process-2:
Traceback (most recent call last):
File "/usr/local/Cellar/python@3.10/3.10.8/Frameworks/Python.framework/Versions/3.10/lib/python3.10/multiprocessing/process.py", line 314, in _bootstrap
self.run()
File "/usr/local/Cellar/python@3.10/3.10.8/Frameworks/Python.framework/Versions/3.10/lib/python3.10/multiprocessing/process.py", line 108, in run
self._target(*self._args, **self._kwargs)
File "test.py", line 18, in child_generator
parent.make_child()
File "<string>", line 2, in make_child
File "/usr/local/Cellar/python@3.10/3.10.8/Frameworks/Python.framework/Versions/3.10/lib/python3.10/multiprocessing/managers.py", line 824, in _callmethod
proxytype = self._manager._registry[token.typeid][-1]
AttributeError: 'NoneType' object has no attribute '_registry'
Environment
- CPython versions tested on: 3.6, 3.7, 3.8, 3.9, 3.10
- Operating system and architecture: macOS Monterey 12.6
Linked PRs
- gh-99598
- Langage dominant
- Python
- Étoiles
- 77.2k
- Forks
- 36k
- Merge moyen
- 1 j 9 h
- PR mergées (30 j)
- 558
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de python/cpython
-
docs pending
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
-
stdlib type-feature
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
-
stdlib type-feature
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
-
build type-bug
Difficulté 2/5 1-3 heures Accessibilité débutants 76/100
-
stdlib topic-email type-feature
Difficulté 2/5 1-3 heures Accessibilité débutants 70/100
Toutes les issues de python/cpython
Issues similaires
-
fix: inaccuracy ⚠️
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
uabrc/uabrc.github.io#1255 · 1 commentaire ·
-
Difficulté 2/5 1-3 heures Accessibilité débutants 84/100
ethereum-optimism/factory#64 ·
-
Difficulté 2/5 1-3 heures Accessibilité débutants 90/100
duckdb/duckdb-python#627 ·
-
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
-
Add link for tutorial Ouvertedocumentation
Difficulté 1/5 Moins d'une heure Accessibilité débutants 78/100
Qiskit/qiskit-addon-sqd#376 ·