This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author amol
Recipients amol
Date 2020-04-16.21:35:30
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1587072930.89.0.0694830896032.issue40307@roundup.psfhosted.org>
In-reply-to
Content
When a new `multiprocessing.managers.BaseManager` instance is made, the client used to connect is not stable across the life of the object.

A very quick example to show that is 

```
from unittest.mock import Mock
from multiprocessing.managers import SyncManager, listener_client

listener_client["faked"] = listener_client["xmlrpclib"] 
sm = SyncManager(serializer="faked")
```

As expected the manager is created with the XmlClient

```
>>> print(sm._Client.__name__)
XmlClient
```

but in reality, if the "faked" serializer is changed in any way

```
listener_client["faked"] = (None, Mock(side_effect=RuntimeError("BROKEN")))
```

When trying to connect, we will unexpectedly connect with whatever it is the serializer registered at the time of connection instead of the one bound to the SyncManager instance 

```
>>> sm.connect()
Traceback (most recent call last):
  File "/home/amol/wrk/cpython/prova.py", line 17, in <module>
    sm.connect()
  File "/home/amol/wrk/cpython/Lib/multiprocessing/managers.py", line 521, in connect
    conn = Client(self._address, authkey=self._authkey)
  ...
  File "/home/amol/wrk/cpython/Lib/unittest/mock.py", line 1152, in _execute_mock_call
    raise effect
RuntimeError: BROKEN
```

To make things worse, we would actually randomly use XmlClient or new one depending on which SyncManager method we call.

This makes also inconvenient to replace the connection layer with a fake one during tests to simulate stub responses. Furthermore the client of the manager is also not propagated properly to the proxies created through that manager making even less consistent the behaviour.
History
Date User Action Args
2020-04-16 21:35:30amolsetrecipients: + amol
2020-04-16 21:35:30amolsetmessageid: <1587072930.89.0.0694830896032.issue40307@roundup.psfhosted.org>
2020-04-16 21:35:30amollinkissue40307 messages
2020-04-16 21:35:30amolcreate