From: Victor Stinner Date: Fri, 21 Apr 2017 11:51:53 +0000 (+0200) Subject: bpo-30106: Fix test_asyncore.test_quick_connect() (#1234) X-Git-Tag: v3.7.0a1~925 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a2c877c3985aba4adb19755e21f477e1c639cfd9;p=python bpo-30106: Fix test_asyncore.test_quick_connect() (#1234) test_quick_connect() runs a thread up to 50 seconds, whereas the socket is connected in 0.2 second and then the thread is expected to end in less than 3 second. On Linux, the thread ends quickly because select() seems to always return quickly. On FreeBSD, sometimes select() fails with timeout and so the thread runs much longer than expected. Fix the thread timeout to fix a race condition in the test. --- diff --git a/Lib/test/test_asyncore.py b/Lib/test/test_asyncore.py index 1e276ec58b..dc2f716e0b 100644 --- a/Lib/test/test_asyncore.py +++ b/Lib/test/test_asyncore.py @@ -781,8 +781,9 @@ class BaseTestAPI: self.skipTest("test specific to AF_INET and AF_INET6") server = BaseServer(self.family, self.addr) + # run the thread 500 ms: the socket should be connected in 200 ms t = threading.Thread(target=lambda: asyncore.loop(timeout=0.1, - count=500)) + count=5)) t.start() try: with socket.socket(self.family, socket.SOCK_STREAM) as s: