[thci] add SSH keepalive (#7999)

Add SSH keepalive to avoid disconnection after idle for a long time.
This commit is contained in:
Jiachen Dong
2022-08-08 18:18:21 -07:00
committed by GitHub
parent 4ce6a4708d
commit 0a41196540
+5
View File
@@ -60,6 +60,8 @@ logging.getLogger('paramiko').setLevel(logging.WARNING)
class SSHHandle(object):
# Unit: second
KEEPALIVE_INTERVAL = 30
def __init__(self, ip, port, username, password):
self.ip = ip
@@ -85,6 +87,9 @@ class SSHHandle(object):
else:
raise
# Avoid SSH disconnection after idle for a long time
self.__handle.get_transport().set_keepalive(self.KEEPALIVE_INTERVAL)
def close(self):
if self.__handle is not None:
self.__handle.close()