forked from M-Labs/artiq
1
0
Fork 0

moninj: make receive_task private again

This commit is contained in:
Sebastien Bourdeauducq 2022-07-02 17:58:24 +08:00
parent 388b81af19
commit d17675e9b5
2 changed files with 9 additions and 4 deletions

View File

@ -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:

View File

@ -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()