From d17675e9b540f3d3c18f0409a2603da690cca030 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Sat, 2 Jul 2022 17:58:24 +0800 Subject: [PATCH] moninj: make receive_task private again --- artiq/coredevice/comm_moninj.py | 9 ++++++--- artiq/frontend/aqctl_moninj_proxy.py | 4 +++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/artiq/coredevice/comm_moninj.py b/artiq/coredevice/comm_moninj.py index 9d0713e0e..e02da526c 100644 --- a/artiq/coredevice/comm_moninj.py +++ b/artiq/coredevice/comm_moninj.py @@ -39,19 +39,22 @@ class CommMonInj: try: self._writer.write(b"ARTIQ moninj\n") - self.receive_task = asyncio.ensure_future(self._receive_cr()) + self._receive_task = asyncio.ensure_future(self._receive_cr()) except: self._writer.close() del self._reader del self._writer raise + def wait_terminate(self): + return self._receive_task + async def close(self): self.disconnect_cb = None try: - self.receive_task.cancel() + self._receive_task.cancel() try: - await asyncio.wait_for(self.receive_task, None) + await asyncio.wait_for(self._receive_task, None) except asyncio.CancelledError: pass finally: diff --git a/artiq/frontend/aqctl_moninj_proxy.py b/artiq/frontend/aqctl_moninj_proxy.py index e86ffff95..8ce6581a9 100755 --- a/artiq/frontend/aqctl_moninj_proxy.py +++ b/artiq/frontend/aqctl_moninj_proxy.py @@ -214,7 +214,9 @@ def main(): loop.run_until_complete(server.start(bind_address, args.port_control)) try: _, pending = loop.run_until_complete(asyncio.wait( - [signal_handler.wait_terminate(), server.wait_terminate(), comm_moninj.receive_task], + [signal_handler.wait_terminate(), + server.wait_terminate(), + comm_moninj.wait_terminate()], return_when=asyncio.FIRST_COMPLETED)) for task in pending: task.cancel()