Skip to content

Commit 2e5cd7e

Browse files
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: cdebb1c ("remote/client: return exit code for ssh/scp/rsync/telnet/video/audio/console") Signed-off-by: Bastian Krause <[email protected]>
1 parent b1d302b commit 2e5cd7e

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

labgrid/remote/client.py

+11-4
Original file line numberDiff line numberDiff line change
@@ -809,6 +809,10 @@ async def _console(self, place, target, timeout, *, logfile=None, loop=False, li
809809
# use zero timeout to prevent blocking sleeps
810810
target.await_resources([resource], timeout=0.0)
811811

812+
if not place.acquired:
813+
print("place released")
814+
return 255
815+
812816
host, port = proxymanager.get_host_and_port(resource)
813817

814818
# check for valid resources
@@ -852,11 +856,14 @@ async def console(self, place, target):
852856
while True:
853857
res = await self._console(place, target, 10.0, logfile=self.args.logfile,
854858
loop=self.args.loop, listen_only=self.args.listenonly)
855-
if res:
856-
exc = InteractiveCommandError("microcom error")
857-
exc.exitcode = res
858-
raise exc
859+
# place released
860+
if res == 255:
861+
break
859862
if not self.args.loop:
863+
if res:
864+
exc = InteractiveCommandError("microcom error")
865+
exc.exitcode = res
866+
raise exc
860867
break
861868
await asyncio.sleep(1.0)
862869
console.needs_target = True

0 commit comments

Comments
 (0)