Skip to content

Commit

Permalink
Merge branch '1.16' into 1.17
Browse files Browse the repository at this point in the history
  • Loading branch information
bitprophet committed Jun 12, 2016
2 parents da125c1 + 0e54d0f commit cd64b7f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
4 changes: 4 additions & 0 deletions paramiko/packet.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ def __init__(self, socket):
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.
Expand Down
13 changes: 11 additions & 2 deletions paramiko/transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -1532,8 +1532,17 @@ def getpeername(self):
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...

Expand Down

0 comments on commit cd64b7f

Please sign in to comment.