forked from M-Labs/artiq
Public receive_task for the use in proxy
Notify proxy and terminate after receive_task end
This commit is contained in:
parent
e1f9feae8b
commit
745f440597
|
@ -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:
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Reference in New Issue