Commit 02763264 authored by Matias Guijarro's avatar Matias Guijarro
Browse files

rpc: only create proxy once, so __wrapped__ always returns the same object;...

rpc: only create proxy once, so __wrapped__ always returns the same object; reconnect if needed in '_call__'
parent 57774c40
...@@ -613,6 +613,9 @@ class RpcConnection: ...@@ -613,6 +613,9 @@ class RpcConnection:
def _call__(self, code, args, kwargs, retry_on_disconnect=True): def _call__(self, code, args, kwargs, retry_on_disconnect=True):
log_debug(self, f"rpc client ({self._address}): '{code}' args={args}") log_debug(self, f"rpc client ({self._address}): '{code}' args={args}")
if self._socket is None:
self.connect()
# Check if already return a sub client # Check if already return a sub client
method_name = args[0] if args else "" method_name = args[0] if args else ""
value = self._subclient.get((code, method_name)) value = self._subclient.get((code, method_name))
...@@ -719,7 +722,7 @@ class Client(proxy.Proxy): ...@@ -719,7 +722,7 @@ class Client(proxy.Proxy):
rpc_connection = RpcConnection(address, disconnect_callback, timeout) rpc_connection = RpcConnection(address, disconnect_callback, timeout)
object.__setattr__(self, "_rpc_connection", rpc_connection) object.__setattr__(self, "_rpc_connection", rpc_connection)
object.__setattr__(self, "_Client__class", None) object.__setattr__(self, "_Client__class", None)
super().__init__(lambda: rpc_connection._proxy) super().__init__(lambda: rpc_connection._proxy, init_once=True)
@property @property
def __class__(self): def __class__(self):
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment