forked from M-Labs/artiq
1
0
Fork 0

Public receive_task for the use in proxy

Notify proxy and terminate after receive_task end
This commit is contained in:
Deepskyhunter 2022-06-23 18:56:44 +08:00 committed by Sébastien Bourdeauducq
parent e1f9feae8b
commit 745f440597
2 changed files with 4 additions and 4 deletions

View File

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

View File

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