Correct position of the except clause in listener loop

This commit is contained in:
Lee Miller 2023-09-01 06:03:45 +03:00
parent acee18f0c4
commit 110dfc3324
Signed by untrusted user: lee.miller
GPG Key ID: 4F97A5EA88F4AB63
1 changed files with 10 additions and 9 deletions

View File

@ -28,13 +28,14 @@ class Listener(threading.Thread):
break
try:
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:
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)