Connection manager tweaks
This commit is contained in:
parent
546ac96850
commit
0cef0219bc
|
@ -59,10 +59,9 @@ class Manager(threading.Thread):
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def clean_connections():
|
def clean_connections():
|
||||||
conns = shared.connections.copy()
|
|
||||||
hosts = set()
|
hosts = set()
|
||||||
outgoing_connections = 0
|
outgoing_connections = 0
|
||||||
for c in conns:
|
for c in shared.connections.copy():
|
||||||
if not c.is_alive() or c.status == 'disconnected':
|
if not c.is_alive() or c.status == 'disconnected':
|
||||||
with shared.connections_lock:
|
with shared.connections_lock:
|
||||||
shared.connections.remove(c)
|
shared.connections.remove(c)
|
||||||
|
@ -70,8 +69,7 @@ class Manager(threading.Thread):
|
||||||
hosts.add(c.host)
|
hosts.add(c.host)
|
||||||
if not c.server:
|
if not c.server:
|
||||||
outgoing_connections += 1
|
outgoing_connections += 1
|
||||||
shared.hosts = hosts
|
if outgoing_connections < shared.outgoing_connections and shared.send_outgoing_connections:
|
||||||
if outgoing_connections < shared.outgoing_connections:
|
|
||||||
to_connect = set()
|
to_connect = set()
|
||||||
if len(shared.unchecked_node_pool) > 12:
|
if len(shared.unchecked_node_pool) > 12:
|
||||||
to_connect.update(random.sample(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)
|
hosts.add(c.host)
|
||||||
with shared.connections_lock:
|
with shared.connections_lock:
|
||||||
shared.connections.add(c)
|
shared.connections.add(c)
|
||||||
|
shared.hosts = hosts
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def shutdown_connections():
|
def shutdown_connections():
|
||||||
|
|
|
@ -5,6 +5,7 @@ import queue
|
||||||
import threading
|
import threading
|
||||||
|
|
||||||
listening_port = 8444
|
listening_port = 8444
|
||||||
|
send_outgoing_connections = True
|
||||||
data_directory = 'minode_data/'
|
data_directory = 'minode_data/'
|
||||||
|
|
||||||
log_level = logging.DEBUG
|
log_level = logging.DEBUG
|
||||||
|
|
Loading…
Reference in New Issue
Block a user