Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions devlib/utils/ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import copy
import functools
from shlex import quote
from weakref import WeakMethod

from paramiko.client import SSHClient, AutoAddPolicy, RejectPolicy
import paramiko.ssh_exception
Expand Down Expand Up @@ -370,7 +371,8 @@ def __init__(self,
self.client = None
try:
self.client = self._make_client()
atexit.register(self.close)
weak_close = WeakMethod(self.close, atexit.unregister)
atexit.register(weak_close)

# Use a marker in the output so that we will be able to differentiate
# target connection issues with "password needed".
Expand Down Expand Up @@ -811,7 +813,9 @@ def __init__(self,
timeout = timeout if timeout is not None else self.default_timeout

self.conn = telnet_get_shell(host, username, password, port, timeout, original_prompt)
atexit.register(self.close)

weak_close = WeakMethod(self.close, atexit.unregister)
atexit.register(weak_close)

def fmt_remote_path(self, path):
return '{}@{}:{}'.format(self.username, self.host, path)
Expand Down