From 6df298f79a8346cf25e2b6c2322eebd3dfd36ae3 Mon Sep 17 00:00:00 2001 From: Bastian Krause Date: Fri, 13 Oct 2023 15:25:36 +0200 Subject: [PATCH] client: fix console --loop on microcom error In certain situation, e.g. if the serial port vanishes (i.e. on-board FTDI chips on power off), microcom returns with 1 and: Got EOF from port connection lost The loop should still continue, so do not raise an exception in this case. This uncovers another problem: if the corresponding place is released, ser2net is stopped from the exporter and the port is set to None. Check that after updating the resource to prevent a crude AssertionError later due to an unavailable port. Fixes: cdebb1cc ("remote/client: return exit code for ssh/scp/rsync/telnet/video/audio/console") Signed-off-by: Bastian Krause --- labgrid/remote/client.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/labgrid/remote/client.py b/labgrid/remote/client.py index 6ef073942..4f97502c8 100755 --- a/labgrid/remote/client.py +++ b/labgrid/remote/client.py @@ -813,6 +813,10 @@ async def _console(self, place, target, timeout, *, logfile=None, loop=False, li # use zero timeout to prevent blocking sleeps target.await_resources([resource], timeout=0.0) + if not place.acquired: + print("place released") + return 255 + host, port = proxymanager.get_host_and_port(resource) # check for valid resources @@ -856,11 +860,14 @@ async def console(self, place, target): while True: res = await self._console(place, target, 10.0, logfile=self.args.logfile, loop=self.args.loop, listen_only=self.args.listenonly) - if res: - exc = InteractiveCommandError("microcom error") - exc.exitcode = res - raise exc + # place released + if res == 255: + break if not self.args.loop: + if res: + exc = InteractiveCommandError("microcom error") + exc.exitcode = res + raise exc break await asyncio.sleep(1.0) console.needs_target = True