[dts] [PATCH] framework: handling _prompt and ssh exceptions

Thinh Tran thinhtr at linux.vnet.ibm.com
Thu May 14 23:18:51 CEST 2020


We may got two exceptions that are raised one right after the other.
It seems to be only in python3 failing to handling it.

In this case are TIMEOUTs of the execution of a command and of the ssh
session:
......
    raise TimeoutException(command, self.get_output_all())
exception.TimeoutException: TIMEOUT on lsof -Fp
/var/run/dpdk/dpdk_73008_20200514164308/config
Error in atexit._run_exitfuncs:
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/pexpect/expect.py", line
111, in expect_loop
    incoming = spawn.read_nonblocking(spawn.maxread, timeout)
  File "/usr/local/lib/python3.6/dist-packages/pexpect/pty_spawn.py",
line 509, in read_nonblocking
    raise TIMEOUT('Timeout exceeded.')
pexpect.exceptions.TIMEOUT: Timeout exceeded.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/pexpect/expect.py", line
119, in expect_loop
    return self.timeout(e)
  File "/usr/local/lib/python3.6/dist-packages/pexpect/expect.py", line
82, in timeout
    raise TIMEOUT(msg)
pexpect.exceptions.TIMEOUT: Timeout exceeded.
<pexpect.pxssh.pxssh object at 0x70b17a7c1be0>
command: /usr/bin/ssh
args: [b'/usr/bin/ssh', b'-q', b'-l', b'root', b'9.114.224.16']
buffer (last 100 chars): ''
.......

Signed-off-by: Thinh Tran <thinhtr at linux.vnet.ibm.com>
---
 framework/ssh_pexpect.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/framework/ssh_pexpect.py b/framework/ssh_pexpect.py
index df610c1..0230207 100644
--- a/framework/ssh_pexpect.py
+++ b/framework/ssh_pexpect.py
@@ -133,7 +133,7 @@ class SSHPexpect:
 
     def __prompt(self, command, timeout):
         if not self.session.prompt(timeout):
-            raise TimeoutException(command, self.get_output_all())
+            raise TimeoutException(command, self.get_output_all()) from None
 
     def __sendline(self, command):
         if not self.isalive():
-- 
2.17.0



More information about the dts mailing list