From 48afc3082a841ca5416fbf7ba8db94f190221638 Mon Sep 17 00:00:00 2001 From: Robey Pointer Date: Sat, 11 Nov 2006 22:30:54 -0800 Subject: [PATCH] [project @ robey@lag.net-20061112063054-bf71926ff8c98c68] a bit of cleanup in close() to try harder to avoid having lingering threads --- paramiko/channel.py | 5 ++++- paramiko/packet.py | 1 + paramiko/transport.py | 3 +++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/paramiko/channel.py b/paramiko/channel.py index b700a1b..5c4d5e8 100644 --- a/paramiko/channel.py +++ b/paramiko/channel.py @@ -92,7 +92,10 @@ class Channel (object): self.exit_status = -1 def __del__(self): - self.close() + try: + self.close() + except: + pass def __repr__(self): """ diff --git a/paramiko/packet.py b/paramiko/packet.py index d43150d..11ccac7 100644 --- a/paramiko/packet.py +++ b/paramiko/packet.py @@ -149,6 +149,7 @@ class Packetizer (object): def close(self): self.__closed = True + self.__socket.close() def set_hexdump(self, hexdump): self.__dump_packets = hexdump diff --git a/paramiko/transport.py b/paramiko/transport.py index 3a0b3a8..a5d342a 100644 --- a/paramiko/transport.py +++ b/paramiko/transport.py @@ -543,10 +543,13 @@ class Transport (threading.Thread): """ Close this session, and any open channels that are tied to it. """ + if not self.active: + return self.active = False self.packetizer.close() for chan in self.channels.values(): chan._unlink() + self.join() def get_remote_server_key(self): """