Close ssh connections when done with them
Newer paramiko leaks connections if they are not explicitly closed. Add a finally handler to always close the ssh connections when we are done with it to avoid leaking these connections. Change-Id: Ia2e53998d362683a42bda074d82e3a3a75f380b4
This commit is contained in:
parent
01a634014e
commit
2de58d560f
@ -396,6 +396,7 @@ class Gerrit(object):
|
||||
return data
|
||||
|
||||
def _ssh(self, command):
|
||||
try:
|
||||
client = paramiko.SSHClient()
|
||||
client.load_system_host_keys()
|
||||
client.set_missing_host_key_policy(paramiko.WarningPolicy())
|
||||
@ -415,6 +416,9 @@ class Gerrit(object):
|
||||
|
||||
err = stderr.read()
|
||||
self.log.debug("SSH received stderr:\n%s" % err)
|
||||
finally:
|
||||
if client:
|
||||
client.close()
|
||||
if ret:
|
||||
raise Exception("Gerrit error executing %s" % command)
|
||||
return (out, err)
|
||||
|
Loading…
Reference in New Issue
Block a user