summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Forcier <jeff@bitprophet.org>2016-06-12 11:24:10 -0700
committerJeff Forcier <jeff@bitprophet.org>2016-06-12 11:24:10 -0700
commit0ebd247127043c57801b91898524738d712e527e (patch)
treec570be8ce6fc33a783623e30a08c545b2721ac06
parentf336a34fafef3b128dc0d81ab5ece74c31ec2016 (diff)
downloadparamiko-0ebd247127043c57801b91898524738d712e527e.tar.gz
Revert Python 2 to original join logic re #520
-rw-r--r--paramiko/transport.py30
1 files changed, 18 insertions, 12 deletions
diff --git a/paramiko/transport.py b/paramiko/transport.py
index 64b96d4f..ce13dab6 100644
--- a/paramiko/transport.py
+++ b/paramiko/transport.py
@@ -55,7 +55,7 @@ from paramiko.kex_gss import KexGSSGex, KexGSSGroup1, KexGSSGroup14, NullHostKey
from paramiko.message import Message
from paramiko.packet import Packetizer, NeedRekeyException
from paramiko.primes import ModulusPack
-from paramiko.py3compat import string_types, long, byte_ord, b, input
+from paramiko.py3compat import string_types, long, byte_ord, b, input, PY2
from paramiko.rsakey import RSAKey
from paramiko.ecdsakey import ECDSAKey
from paramiko.server import ServerInterface
@@ -1532,17 +1532,23 @@ class Transport (threading.Thread, ClosingContextManager):
def stop_thread(self):
self.active = False
self.packetizer.close()
- # 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)
+ if PY2:
+ # Original join logic; #520 doesn't appear commonly present under
+ # Python 2.
+ while self.is_alive() and self is not threading.current_thread():
+ self.join(10)
+ else:
+ # 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...