Connection manager tweaks

This commit is contained in:
TheKysek 2016-07-09 19:37:54 +02:00
parent 546ac96850
commit 0cef0219bc
2 changed files with 4 additions and 4 deletions

View File

@ -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():

View File

@ -5,6 +5,7 @@ import queue
import threading
listening_port = 8444
send_outgoing_connections = True
data_directory = 'minode_data/'
log_level = logging.DEBUG