Limit number of connections
This commit is contained in:
parent
0c5c58e126
commit
1146100168
|
@ -28,6 +28,9 @@ class Listener(threading.Thread):
|
||||||
conn, addr = self.s.accept()
|
conn, addr = self.s.accept()
|
||||||
logging.info('Incoming connection from: {}:{}'.format(addr[0], addr[1]))
|
logging.info('Incoming connection from: {}:{}'.format(addr[0], addr[1]))
|
||||||
with shared.connections_lock:
|
with shared.connections_lock:
|
||||||
|
if len(shared.connections) > shared.connection_limit:
|
||||||
|
conn.close()
|
||||||
|
else:
|
||||||
c = Connection(addr[0], addr[1], conn)
|
c = Connection(addr[0], addr[1], conn)
|
||||||
c.start()
|
c.start()
|
||||||
shared.connections.add(c)
|
shared.connections.add(c)
|
||||||
|
|
|
@ -42,6 +42,7 @@ node_pool = set()
|
||||||
unchecked_node_pool = set()
|
unchecked_node_pool = set()
|
||||||
|
|
||||||
outgoing_connections = 8
|
outgoing_connections = 8
|
||||||
|
connection_limit = 150
|
||||||
|
|
||||||
objects = {}
|
objects = {}
|
||||||
objects_lock = threading.Lock()
|
objects_lock = threading.Lock()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user