mirror of https://github.com/m-labs/artiq.git
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:
|
try:
|
||||||
self._writer.write(b"ARTIQ moninj\n")
|
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:
|
except:
|
||||||
self._writer.close()
|
self._writer.close()
|
||||||
del self._reader
|
del self._reader
|
||||||
|
@ -49,9 +49,9 @@ class CommMonInj:
|
||||||
async def close(self):
|
async def close(self):
|
||||||
self.disconnect_cb = None
|
self.disconnect_cb = None
|
||||||
try:
|
try:
|
||||||
self._receive_task.cancel()
|
self.receive_task.cancel()
|
||||||
try:
|
try:
|
||||||
await asyncio.wait_for(self._receive_task, None)
|
await asyncio.wait_for(self.receive_task, None)
|
||||||
except asyncio.CancelledError:
|
except asyncio.CancelledError:
|
||||||
pass
|
pass
|
||||||
finally:
|
finally:
|
||||||
|
|
|
@ -214,7 +214,7 @@ def main():
|
||||||
loop.run_until_complete(server.start(bind_address, args.port_control))
|
loop.run_until_complete(server.start(bind_address, args.port_control))
|
||||||
try:
|
try:
|
||||||
_, pending = loop.run_until_complete(asyncio.wait(
|
_, 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))
|
return_when=asyncio.FIRST_COMPLETED))
|
||||||
for task in pending:
|
for task in pending:
|
||||||
task.cancel()
|
task.cancel()
|
||||||
|
|
Loading…
Reference in New Issue