From 8749c786229108b5e2b9fcb26272ffae7b7f3f81 Mon Sep 17 00:00:00 2001 From: Victor Shyba Date: Sun, 14 Jul 2019 00:46:22 -0300 Subject: [PATCH] close daemon connector on server close to avoid errors on tests --- torba/torba/server/daemon.py | 5 +++++ torba/torba/server/server.py | 1 + 2 files changed, 6 insertions(+) diff --git a/torba/torba/server/daemon.py b/torba/torba/server/daemon.py index dd0144fe0..72a87675f 100644 --- a/torba/torba/server/daemon.py +++ b/torba/torba/server/daemon.py @@ -57,6 +57,11 @@ class Daemon: self.available_rpcs = {} self.connector = aiohttp.TCPConnector() + async def close(self): + if self.connector: + await self.connector.close() + self.connector = None + def set_url(self, url): """Set the URLS to the given list, and switch to the first one.""" urls = url.split(',') diff --git a/torba/torba/server/server.py b/torba/torba/server/server.py index 893860db5..391e1cb2f 100644 --- a/torba/torba/server/server.py +++ b/torba/torba/server/server.py @@ -146,6 +146,7 @@ class Server: task.cancel() await asyncio.wait(self.cancellable_tasks) self.shutdown_event.set() + await self.daemon.close() def run(self): loop = asyncio.get_event_loop()