From 962be9d1fb47e08753b1da5a4c0f8fdbf3c049ed Mon Sep 17 00:00:00 2001 From: TheKysek Date: Thu, 25 May 2017 11:57:29 +0200 Subject: [PATCH] Simpler method of stopping connection threads --- src/connection.py | 2 +- src/manager.py | 7 ------- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/src/connection.py b/src/connection.py index 992d408..16278d4 100644 --- a/src/connection.py +++ b/src/connection.py @@ -105,7 +105,7 @@ class Connection(threading.Thread): self.status = 'disconnecting' if time.time() - self.last_message_sent > 300 and self.status == 'fully_established': self.send_queue.put(message.Message(b'pong', b'')) - if self.status == 'disconnecting': + if self.status == 'disconnecting' or shared.shutting_down: data = None if not data: self.status = 'disconnected' diff --git a/src/manager.py b/src/manager.py index fd4c24a..3511257 100644 --- a/src/manager.py +++ b/src/manager.py @@ -38,8 +38,6 @@ class Manager(threading.Thread): self.last_pickled_nodes = now if shared.shutting_down: - logging.debug('Shutting down connections') - self.shutdown_connections() logging.debug('Shutting down Manager') break @@ -86,11 +84,6 @@ class Manager(threading.Thread): shared.connections.add(c) shared.hosts = hosts - @staticmethod - def shutdown_connections(): - for c in shared.connections.copy(): - c.send_queue.put(None) - @staticmethod def pickle_objects(): try: