[Python-checkins] cpython: Set a time threshold in test_asyncore.capture_server so that tests don't

kristjan.jonsson python-checkins at python.org
Fri Apr 6 16:42:06 CEST 2012


http://hg.python.org/cpython/rev/d8c5c0f7aa56
changeset:   76137:d8c5c0f7aa56
user:        Kristján Valur Jónsson <kristjan at ccpgames.com>
date:        Fri Apr 06 14:37:45 2012 +0000
summary:
  Set a time threshold in test_asyncore.capture_server so that tests don't
deadlock if the main thread fails before sending all the data.

files:
  Lib/test/test_asyncore.py |  7 ++++---
  1 files changed, 4 insertions(+), 3 deletions(-)


diff --git a/Lib/test/test_asyncore.py b/Lib/test/test_asyncore.py
--- a/Lib/test/test_asyncore.py
+++ b/Lib/test/test_asyncore.py
@@ -74,15 +74,16 @@
         pass
     else:
         n = 200
-        while n > 0:
-            r, w, e = select.select([conn], [], [])
+        start = time.time()
+        while n > 0 and time.time() - start < 3.0:
+            r, w, e = select.select([conn], [], [], 0.1)
             if r:
+                n -= 1
                 data = conn.recv(10)
                 # keep everything except for the newline terminator
                 buf.write(data.replace(b'\n', b''))
                 if b'\n' in data:
                     break
-            n -= 1
             time.sleep(0.01)
 
         conn.close()

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list