Browse Source

Using xlist to remove closed sockets

feature/balanceutils
klonfish 8 years ago committed by klonfish
parent
commit
7bb376d516
  1. 10
      wii-pair/daemon.py

10
wii-pair/daemon.py

@ -172,12 +172,15 @@ s.listen(1)
try: try:
conns = [] conns = []
while True: while True:
rlist, wlist, xlist = select.select([s]+conns, [], []) rlist, wlist, xlist = select.select([s]+conns, [], conns)
if s in rlist: if s in rlist:
conn, addr = s.accept() conn, addr = s.accept()
conns.append(conn) conns.append(conn)
rlist.remove(s) rlist.remove(s)
for sock in xlist:
conns.remove(sock)
for sock in rlist: for sock in rlist:
try: try:
m = sock.recv(1) m = sock.recv(1)
@ -185,11 +188,6 @@ try:
conns.remove(sock) conns.remove(sock)
continue continue
if len(m) == 0:
conn.close()
conns.remove(sock)
continue
r = b'' r = b''
for w in wiis: for w in wiis:
if w.pos_x is None: if w.pos_x is None:

Loading…
Cancel
Save