forked from M-Labs/artiq
moninj,corelog: fix/cleanup exception handling (#1897)
This commit is contained in:
parent
02b086c9e5
commit
388b81af19
|
@ -91,6 +91,10 @@ class CommMonInj:
|
|||
self.injection_status_cb(channel, override, value)
|
||||
else:
|
||||
raise ValueError("Unknown packet type", ty)
|
||||
except asyncio.CancelledError:
|
||||
raise
|
||||
except:
|
||||
logger.error("Moninj connection terminating with exception", exc_info=True)
|
||||
finally:
|
||||
if self.disconnect_cb is not None:
|
||||
self.disconnect_cb()
|
||||
|
|
|
@ -40,6 +40,7 @@ async def get_logs_sim(host):
|
|||
|
||||
|
||||
async def get_logs(host):
|
||||
try:
|
||||
reader, writer = await async_open_connection(
|
||||
host,
|
||||
1380,
|
||||
|
@ -78,6 +79,10 @@ async def get_logs(host):
|
|||
name = 'firmware.' + m.group(2).replace('::', '.')
|
||||
text = m.group(3)
|
||||
log_with_name(name, level, text)
|
||||
except asyncio.CancelledError:
|
||||
raise
|
||||
except:
|
||||
logger.error("Logging connection terminating with exception", exc_info=True)
|
||||
|
||||
|
||||
def main():
|
||||
|
@ -99,8 +104,7 @@ def main():
|
|||
_, pending = loop.run_until_complete(asyncio.wait(
|
||||
[signal_handler.wait_terminate(),
|
||||
server.wait_terminate(),
|
||||
get_logs_task
|
||||
],
|
||||
get_logs_task],
|
||||
return_when=asyncio.FIRST_COMPLETED))
|
||||
for task in pending:
|
||||
task.cancel()
|
||||
|
@ -108,8 +112,6 @@ def main():
|
|||
loop.run_until_complete(server.stop())
|
||||
finally:
|
||||
pass
|
||||
except Exception:
|
||||
logger.error("Termination due to exception", exc_info=True)
|
||||
finally:
|
||||
signal_handler.teardown()
|
||||
finally:
|
||||
|
|
Loading…
Reference in New Issue