Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b1994b4

Browse files
Added a select.select call in the test server loop to make sure the
socket is ready to be read from before attempting a read (this prevents an error 10035 on some Windows platforms). [GSoC - Alan McIntyre]
1 parent 219336a commit b1994b4

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

Lib/test/test_asyncore.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,13 @@ def capture_server(evt, buf):
6565
else:
6666
n = 200
6767
while n > 0:
68-
data = conn.recv(10)
69-
# keep everything except for the newline terminator
70-
buf.write(data.replace('\n', ''))
71-
if '\n' in data:
72-
break
68+
r, w, e = select.select([conn], [], [])
69+
if r:
70+
data = conn.recv(10)
71+
# keep everything except for the newline terminator
72+
buf.write(data.replace('\n', ''))
73+
if '\n' in data:
74+
break
7375
n -= 1
7476
time.sleep(0.01)
7577

0 commit comments

Comments
 (0)