Issue #20910: Make tests more reliable, less dependent on time

* Tolerate 10 seconds instead of 3 seconds for slow test
* Faster test, use sleep of 100 ms instead of 1 sec
* Replace a number of iterations with an explicit deadline for the timeout
This commit is contained in:
Victor Stinner 2014-03-18 00:39:04 +01:00
parent f8cbf78bbd
commit 1e48eb3b9b
5 changed files with 19 additions and 10 deletions

View file

@ -87,10 +87,11 @@ class DocXMLRPCHTTPGETServer(unittest.TestCase):
threading.Thread(target=server, args=(self.evt, 1)).start()
# wait for port to be assigned
n = 1000
while n > 0 and PORT is None:
time.sleep(0.001)
n -= 1
deadline = time.monotonic() + 10.0
while PORT is None:
time.sleep(0.010)
if time.monotonic() > deadline:
break
self.client = http.client.HTTPConnection("localhost:%d" % PORT)