From 0cef0219bc5f5cc6c7a1b725a274153d2de5e485 Mon Sep 17 00:00:00 2001 From: TheKysek Date: Sat, 9 Jul 2016 19:37:54 +0200 Subject: [PATCH] Connection manager tweaks --- src/manager.py | 7 +++---- src/shared.py | 1 + 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/manager.py b/src/manager.py index 2c195b9..ecd387b 100644 --- a/src/manager.py +++ b/src/manager.py @@ -59,10 +59,9 @@ class Manager(threading.Thread): @staticmethod def clean_connections(): - conns = shared.connections.copy() hosts = set() outgoing_connections = 0 - for c in conns: + for c in shared.connections.copy(): if not c.is_alive() or c.status == 'disconnected': with shared.connections_lock: shared.connections.remove(c) @@ -70,8 +69,7 @@ class Manager(threading.Thread): hosts.add(c.host) if not c.server: outgoing_connections += 1 - shared.hosts = hosts - if outgoing_connections < shared.outgoing_connections: + if outgoing_connections < shared.outgoing_connections and shared.send_outgoing_connections: to_connect = set() if len(shared.unchecked_node_pool) > 12: to_connect.update(random.sample(shared.unchecked_node_pool, 12)) @@ -90,6 +88,7 @@ class Manager(threading.Thread): hosts.add(c.host) with shared.connections_lock: shared.connections.add(c) + shared.hosts = hosts @staticmethod def shutdown_connections(): diff --git a/src/shared.py b/src/shared.py index 1894ff4..d0fee06 100644 --- a/src/shared.py +++ b/src/shared.py @@ -5,6 +5,7 @@ import queue import threading listening_port = 8444 +send_outgoing_connections = True data_directory = 'minode_data/' log_level = logging.DEBUG