]> granicus.if.org Git - python/commitdiff
Added a select.select call in the test server loop to make sure the
authorFacundo Batista <facundobatista@gmail.com>
Thu, 19 Jul 2007 23:57:38 +0000 (23:57 +0000)
committerFacundo Batista <facundobatista@gmail.com>
Thu, 19 Jul 2007 23:57:38 +0000 (23:57 +0000)
socket is ready to be read from before attempting a read (this
prevents an error 10035 on some Windows platforms). [GSoC - Alan
McIntyre]

Lib/test/test_asyncore.py

index 7602b9fca66e69d7515de5dacb6e56fa197527f7..03481e809f4a8d93401642106f9d533f26d4d046 100644 (file)
@@ -65,11 +65,13 @@ def capture_server(evt, buf):
     else:
         n = 200
         while n > 0:
-            data = conn.recv(10)
-            # keep everything except for the newline terminator
-            buf.write(data.replace('\n', ''))
-            if '\n' in data:
-                break
+            r, w, e = select.select([conn], [], [])
+            if r:
+                data = conn.recv(10)
+                # keep everything except for the newline terminator
+                buf.write(data.replace('\n', ''))
+                if '\n' in data:
+                    break
             n -= 1
             time.sleep(0.01)