From 7bb376d5164d5774c16c40d6777f91710312fea7 Mon Sep 17 00:00:00 2001 From: klonfish Date: Tue, 27 Dec 2016 01:33:02 +0100 Subject: [PATCH] Using xlist to remove closed sockets --- wii-pair/daemon.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/wii-pair/daemon.py b/wii-pair/daemon.py index 7bcba47..f53481b 100755 --- a/wii-pair/daemon.py +++ b/wii-pair/daemon.py @@ -172,12 +172,15 @@ s.listen(1) try: conns = [] while True: - rlist, wlist, xlist = select.select([s]+conns, [], []) + rlist, wlist, xlist = select.select([s]+conns, [], conns) if s in rlist: conn, addr = s.accept() conns.append(conn) rlist.remove(s) + for sock in xlist: + conns.remove(sock) + for sock in rlist: try: m = sock.recv(1) @@ -185,11 +188,6 @@ try: conns.remove(sock) continue - if len(m) == 0: - conn.close() - conns.remove(sock) - continue - r = b'' for w in wiis: if w.pos_x is None: