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:
|
||||
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:
|
||||
|
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user