summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJeff Forcier <jeff@bitprophet.org>2016-06-11 23:29:06 -0700
committerJeff Forcier <jeff@bitprophet.org>2016-06-11 23:29:06 -0700
commitb4216350a0ef1bc7118f6eebe158a155c96a41fd (patch)
tree360b94f3ef9935b543b02e2a8befab6e3df3f9fa
parent50de173becde7446fc725422bbf2f8aa3b2708da (diff)
parentcd64b7f78dca28ac771a8cf5b3a0cbfec51e1d09 (diff)
Merge branch '1.17' into 2.0
-rw-r--r--paramiko/packet.py4
-rw-r--r--paramiko/transport.py13
2 files changed, 15 insertions, 2 deletions
diff --git a/paramiko/packet.py b/paramiko/packet.py
index 00cf5657..c943fe3c 100644
--- a/paramiko/packet.py
+++ b/paramiko/packet.py
@@ -103,6 +103,10 @@ class Packetizer (object):
self.__handshake_complete = False
self.__timer_expired = False
+ @property
+ def closed(self):
+ return self.__closed
+
def set_log(self, log):
"""
Set the Python log object to use for logging.
diff --git a/paramiko/transport.py b/paramiko/transport.py
index d362ea64..000a98f3 100644
--- a/paramiko/transport.py
+++ b/paramiko/transport.py
@@ -1533,8 +1533,17 @@ class Transport (threading.Thread, ClosingContextManager):
def stop_thread(self):
self.active = False
self.packetizer.close()
- while self.is_alive() and (self is not threading.current_thread()):
- self.join(10)
+ # Keep trying to join() our main thread, quickly, until:
+ # * We join()ed successfully (self.is_alive() == False)
+ # * Or it looks like we've hit issue #520 (socket.recv hitting some
+ # race condition preventing it from timing out correctly), wherein our
+ # socket and packetizer are both closed (but where we'd otherwise be
+ # sitting forever on that recv()).
+ while (
+ self.is_alive() and self is not threading.current_thread()
+ and not self.sock._closed and not self.packetizer.closed
+ ):
+ self.join(0.1)
### internals...