From 5f08596807e499ca96ce00418adfab5423d620ed Mon Sep 17 00:00:00 2001 From: Fred De Backer Date: Tue, 19 May 2020 21:12:25 +0200 Subject: [PATCH 1/4] Add time.sleep() to _read_until This should release the Python Gobal Interpreter Lock once per iteration, so the I/O bound paramiko thread get's a chance to run. --- src/SSHLibrary/abstractclient.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/SSHLibrary/abstractclient.py b/src/SSHLibrary/abstractclient.py index 1c233f8ee..d7f46616c 100644 --- a/src/SSHLibrary/abstractclient.py +++ b/src/SSHLibrary/abstractclient.py @@ -442,6 +442,7 @@ def _read_until(self, matcher, expected, timeout=None): output += self.read_char() if matcher(output): return output + time.sleep(.00001) # Release GIL so paramiko I/O thread can run raise SSHClientException("No match found for '%s' in %s\nOutput:\n%s." % (expected, timeout, output)) From 412d82696dc6d930422cf2bedcbc629662d8ef28 Mon Sep 17 00:00:00 2001 From: Fred De Backer Date: Tue, 19 May 2020 22:06:49 +0200 Subject: [PATCH 2/4] Change sleep value after review comment --- src/SSHLibrary/abstractclient.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SSHLibrary/abstractclient.py b/src/SSHLibrary/abstractclient.py index d7f46616c..ec2b07f4c 100644 --- a/src/SSHLibrary/abstractclient.py +++ b/src/SSHLibrary/abstractclient.py @@ -442,7 +442,7 @@ def _read_until(self, matcher, expected, timeout=None): output += self.read_char() if matcher(output): return output - time.sleep(.00001) # Release GIL so paramiko I/O thread can run + time.sleep(0) # Release GIL so paramiko I/O thread can run raise SSHClientException("No match found for '%s' in %s\nOutput:\n%s." % (expected, timeout, output)) From 0a05e955a3e9538e05847ac4df0b4965cb079a73 Mon Sep 17 00:00:00 2001 From: Fred De Backer Date: Tue, 19 May 2020 22:30:34 +0200 Subject: [PATCH 3/4] Revert "Change sleep value after review comment" This reverts commit 412d82696dc6d930422cf2bedcbc629662d8ef28. --- src/SSHLibrary/abstractclient.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SSHLibrary/abstractclient.py b/src/SSHLibrary/abstractclient.py index ec2b07f4c..d7f46616c 100644 --- a/src/SSHLibrary/abstractclient.py +++ b/src/SSHLibrary/abstractclient.py @@ -442,7 +442,7 @@ def _read_until(self, matcher, expected, timeout=None): output += self.read_char() if matcher(output): return output - time.sleep(0) # Release GIL so paramiko I/O thread can run + time.sleep(.00001) # Release GIL so paramiko I/O thread can run raise SSHClientException("No match found for '%s' in %s\nOutput:\n%s." % (expected, timeout, output)) From 4abade016c2f4d22d3ffa6197d1194efb6fb4fbd Mon Sep 17 00:00:00 2001 From: satheesh Date: Fri, 3 Jul 2020 23:07:49 +0530 Subject: [PATCH 4/4] _read_until long wait for huge output fix --- src/SSHLibrary/abstractclient.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SSHLibrary/abstractclient.py b/src/SSHLibrary/abstractclient.py index d7f46616c..1222066ae 100644 --- a/src/SSHLibrary/abstractclient.py +++ b/src/SSHLibrary/abstractclient.py @@ -439,7 +439,7 @@ def _read_until(self, matcher, expected, timeout=None): timeout = TimeEntry(timeout) if timeout else self.config.get('timeout') max_time = time.time() + timeout.value while time.time() < max_time: - output += self.read_char() + output += self.read() if matcher(output): return output time.sleep(.00001) # Release GIL so paramiko I/O thread can run