summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJeff Forcier <jeff@bitprophet.org>2017-02-20 14:41:16 -0800
committerJeff Forcier <jeff@bitprophet.org>2017-02-20 14:41:16 -0800
commit6830a905cc38261d9e4054b87294959dac6a1b5c (patch)
tree1cc0c230c7c6750ad0de6cf363247790a8c5e935
parentc92920043f2763b72605e4026c537afa5a859a03 (diff)
parenta16a28afbf643b1219796f041edde05109fa2000 (diff)
Merge branch '2.1'
-rw-r--r--paramiko/client.py1
-rw-r--r--paramiko/transport.py5
-rw-r--r--sites/www/changelog.rst7
3 files changed, 13 insertions, 0 deletions
diff --git a/paramiko/client.py b/paramiko/client.py
index a2c02c51..5118682f 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 49a239c2..c4f0ca7c 100644
--- a/paramiko/transport.py
+++ b/paramiko/transport.py
@@ -283,6 +283,7 @@ class Transport (threading.Thread, ClosingContextManager):
arguments.
"""
self.active = False
+ self._sshclient = None
if isinstance(sock, string_types):
# convert "host:port" into (host, port)
@@ -642,6 +643,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.
@@ -652,6 +656,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 9084f1be..b53f0828 100644
--- a/sites/www/changelog.rst
+++ b/sites/www/changelog.rst
@@ -2,6 +2,13 @@
Changelog
=========
+* :bug:`44 (1.17+)` (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