mirror of
https://github.com/ARM-software/devlib.git
synced 2025-01-31 02:00:45 +00:00
ssh: Use atexit to automatically close ssh connections
As stated in https://github.com/ARM-software/devlib/issues/308 devlib can leave ssh connections open after they are no longer in use, so now register the close method with atexit so the connections are no longer left open upon exit.
This commit is contained in:
parent
512c5f3737
commit
b0463e58d8
@ -25,6 +25,7 @@ import shutil
|
||||
import socket
|
||||
import sys
|
||||
import time
|
||||
import atexit
|
||||
|
||||
# pylint: disable=import-error,wrong-import-position,ungrouped-imports,wrong-import-order
|
||||
import pexpect
|
||||
@ -181,6 +182,7 @@ class SshConnection(object):
|
||||
logger.debug('Logging in {}@{}'.format(username, host))
|
||||
timeout = timeout if timeout is not None else self.default_timeout
|
||||
self.conn = ssh_get_shell(host, username, password, self.keyfile, port, timeout, False, None)
|
||||
atexit.register(self.close)
|
||||
|
||||
def push(self, source, dest, timeout=30):
|
||||
dest = '"{}"@"{}":"{}"'.format(escape_double_quotes(self.username),
|
||||
|
Loading…
x
Reference in New Issue
Block a user