diff options
author | Jeff Forcier <jeff@bitprophet.org> | 2017-02-20 14:39:55 -0800 |
---|---|---|
committer | Jeff Forcier <jeff@bitprophet.org> | 2017-02-20 14:39:55 -0800 |
commit | ef7873744772b4575972e265227895c6347eda98 (patch) | |
tree | 00fd1a1992f10e1157f55f93c8ed73501c4bfc13 | |
parent | df55e09588ac8945ac3b3298e26695306492d307 (diff) | |
parent | a39a1eeed691b9c4e191dbe4b8716fb7682971fa (diff) |
Merge branch '1.17' into 1.18
-rw-r--r-- | paramiko/client.py | 1 | ||||
-rw-r--r-- | paramiko/transport.py | 5 | ||||
-rw-r--r-- | sites/www/changelog.rst | 7 |
3 files changed, 13 insertions, 0 deletions
diff --git a/paramiko/client.py b/paramiko/client.py index 53282c01..ad5b5d8a 100644 --- a/paramiko/client.py +++ b/paramiko/client.py @@ -336,6 +336,7 @@ class SSHClient (ClosingContextManager): if banner_timeout is not None: t.banner_timeout = banner_timeout t.start_client(timeout=timeout) + t.set_sshclient(self) ResourceManager.register(self, t) server_key = t.get_remote_server_key() diff --git a/paramiko/transport.py b/paramiko/transport.py index b286fc5c..8bf582cc 100644 --- a/paramiko/transport.py +++ b/paramiko/transport.py @@ -282,6 +282,7 @@ class Transport (threading.Thread, ClosingContextManager): arguments. """ self.active = False + self._sshclient = None if isinstance(sock, string_types): # convert "host:port" into (host, port) @@ -641,6 +642,9 @@ class Transport (threading.Thread, ClosingContextManager): Transport._modulus_pack = None return False + def set_sshclient(self, sshclient): + self._sshclient = sshclient + def close(self): """ Close this session, and any open channels that are tied to it. @@ -651,6 +655,7 @@ class Transport (threading.Thread, ClosingContextManager): for chan in list(self._channels.values()): chan._unlink() self.sock.close() + self._sshclient = None def get_remote_server_key(self): """ diff --git a/sites/www/changelog.rst b/sites/www/changelog.rst index 0c323846..9ececfc1 100644 --- a/sites/www/changelog.rst +++ b/sites/www/changelog.rst @@ -2,6 +2,13 @@ Changelog ========= +* :bug:`44` (via :issue:`891`) `SSHClient <paramiko.client.SSHClient>` now + gives its internal `Transport <paramiko.transport.Transport>` a handle on + itself, preventing garbage collection of the client until the session is + closed. Without this, some code which returns stream or transport objects + without the client that generated them, would result in premature session + closure when the client was GCd. Credit: ``@w31rd0`` for original report, + Omer Anson for the patch. * :bug:`713 (1.17+)` (via :issue:`714` and :issue:`889`) Don't pass initialization vectors to PyCrypto when dealing with counter-mode ciphers; newer PyCrypto versions throw an exception otherwise (older ones simply |