diff options
Diffstat (limited to 'paramiko/transport.py')
-rw-r--r-- | paramiko/transport.py | 34 |
1 files changed, 14 insertions, 20 deletions
diff --git a/paramiko/transport.py b/paramiko/transport.py index 930ba4d4..23eda83b 100644 --- a/paramiko/transport.py +++ b/paramiko/transport.py @@ -101,7 +101,7 @@ from paramiko.kex_gss import KexGSSGex, KexGSSGroup1, KexGSSGroup14 from paramiko.message import Message from paramiko.packet import Packetizer, NeedRekeyException from paramiko.primes import ModulusPack -from paramiko.py3compat import string_types, long, b, input, PY2 +from paramiko.py3compat import string_types, long, b, input from paramiko.rsakey import RSAKey from paramiko.ecdsakey import ECDSAKey from paramiko.server import ServerInterface @@ -1845,25 +1845,19 @@ class Transport(threading.Thread, ClosingContextManager): def stop_thread(self): self.active = False self.packetizer.close() - 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) + # 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... |