forked from M-Labs/artiq
moninj: make receive_task private again
This commit is contained in:
parent
388b81af19
commit
d17675e9b5
|
@ -39,19 +39,22 @@ 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
|
||||||
del self._writer
|
del self._writer
|
||||||
raise
|
raise
|
||||||
|
|
||||||
|
def wait_terminate(self):
|
||||||
|
return self._receive_task
|
||||||
|
|
||||||
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,9 @@ 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(), comm_moninj.receive_task],
|
[signal_handler.wait_terminate(),
|
||||||
|
server.wait_terminate(),
|
||||||
|
comm_moninj.wait_terminate()],
|
||||||
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