From 745f4405970def0be40a5b3365af5693805ee8ec Mon Sep 17 00:00:00 2001 From: Deepskyhunter Date: Thu, 23 Jun 2022 18:56:44 +0800 Subject: [PATCH] Public receive_task for the use in proxy Notify proxy and terminate after receive_task end --- artiq/coredevice/comm_moninj.py | 6 +++--- artiq/frontend/aqctl_moninj_proxy.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/artiq/coredevice/comm_moninj.py b/artiq/coredevice/comm_moninj.py index b5c2ee40d..26505a08d 100644 --- a/artiq/coredevice/comm_moninj.py +++ b/artiq/coredevice/comm_moninj.py @@ -39,7 +39,7 @@ 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 @@ -49,9 +49,9 @@ class CommMonInj: 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 54d8d0833..e86ffff95 100755 --- a/artiq/frontend/aqctl_moninj_proxy.py +++ b/artiq/frontend/aqctl_moninj_proxy.py @@ -214,7 +214,7 @@ 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()], + [signal_handler.wait_terminate(), server.wait_terminate(), comm_moninj.receive_task], return_when=asyncio.FIRST_COMPLETED)) for task in pending: task.cancel()