Improving the network communication #4
|
@ -28,13 +28,14 @@ class Listener(threading.Thread):
|
||||||
break
|
break
|
||||||
try:
|
try:
|
||||||
conn, addr = self.s.accept()
|
conn, addr = self.s.accept()
|
||||||
logging.info('Incoming connection from: %s:%i', *addr[:2])
|
|
||||||
with shared.connections_lock:
|
|
||||||
if len(shared.connections) > shared.connection_limit:
|
|
||||||
conn.close()
|
|
||||||
else:
|
|
||||||
c = Connection(*addr[:2], conn, server=True)
|
|
||||||
c.start()
|
|
||||||
shared.connections.add(c)
|
|
||||||
except socket.timeout:
|
except socket.timeout:
|
||||||
pass
|
continue
|
||||||
|
|
||||||
|
logging.info('Incoming connection from: %s:%i', *addr[:2])
|
||||||
|
with shared.connections_lock:
|
||||||
|
if len(shared.connections) > shared.connection_limit:
|
||||||
|
conn.close()
|
||||||
|
else:
|
||||||
|
c = Connection(*addr[:2], conn, server=True)
|
||||||
|
c.start()
|
||||||
|
shared.connections.add(c)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user