diff --git a/synapse/telepath.py b/synapse/telepath.py index 4c8e69319e..930a70b8a3 100644 --- a/synapse/telepath.py +++ b/synapse/telepath.py @@ -688,10 +688,6 @@ async def proxy(self, timeout=10): async def _initTeleLink(self, url): if self._t_proxy is not None: await self._t_proxy.fini() - if self._t_named_meths: - for name in self._t_named_meths: - delattr(self, name) - self._t_named_meths.clear() self._t_proxy = await openurl(url, **self._t_opts) self._t_methinfo = self._t_proxy.methinfo @@ -701,6 +697,10 @@ async def _initTeleLink(self, url): await self._t_onlink(self._t_proxy) async def fini(): + if self._t_named_meths: + for name in self._t_named_meths: + delattr(self, name) + self._t_named_meths.clear() await self._fireLinkLoop() self._t_proxy.onfini(fini) diff --git a/synapse/tests/test_telepath.py b/synapse/tests/test_telepath.py index a1f6a72ffe..29e617ba21 100644 --- a/synapse/tests/test_telepath.py +++ b/synapse/tests/test_telepath.py @@ -1155,7 +1155,7 @@ def bar(self): self.eq(prox._t_named_meths, {'foo', 'bar'}) # Disable the dmon and wait for the proxy to have been fini'd - await dmon.setReady(False) + dmon.schedCoro(dmon.setReady(False)) self.true(await prox._t_proxy.waitfini(10)) # Swap out the object and reconnect