diff --git a/src/wsdd.py b/src/wsdd.py index e102422..b087862 100755 --- a/src/wsdd.py +++ b/src/wsdd.py @@ -1127,6 +1127,7 @@ class ApiServer: def __init__(self, aio_loop: asyncio.AbstractEventLoop, listen_address: bytes, address_monitor: 'NetworkAddressMonitor') -> None: self.server = None + self.clients = set() self.address_monitor = address_monitor # defer server creation @@ -1146,6 +1147,7 @@ async def create_server(self, aio_loop: asyncio.AbstractEventLoop, listen_addres self.on_connect, path=listen_address)) async def on_connect(self, read_stream: asyncio.StreamReader, write_stream: asyncio.StreamWriter) -> None: + self.clients.add(write_stream.transport) while True: try: line = await read_stream.readline() @@ -1219,6 +1221,8 @@ async def cleanup(self) -> None: await self.create_task if self.server: self.server.close() + for transport in self.clients: + transport.close() await self.server.wait_closed()