From 37184295dc70936c05803d5a4fafe3ea77a3fd28 Mon Sep 17 00:00:00 2001 From: Neal Norwitz Date: Sat, 26 Jan 2008 21:21:59 +0000 Subject: [PATCH] Reduce the race condition by signalling when the server is ready and not trying to connect before. --- Lib/test/test_telnetlib.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Lib/test/test_telnetlib.py b/Lib/test/test_telnetlib.py index 0a3604e5ae1..3a53ad9079c 100644 --- a/Lib/test/test_telnetlib.py +++ b/Lib/test/test_telnetlib.py @@ -13,6 +13,7 @@ def server(evt): serv.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) serv.bind(("", 9091)) serv.listen(5) + evt.set() try: conn, addr = serv.accept() except socket.timeout: @@ -26,6 +27,8 @@ class GeneralTests(TestCase): def setUp(self): self.evt = threading.Event() threading.Thread(target=server, args=(self.evt,)).start() + self.evt.wait() + self.evt.clear() time.sleep(.1) def tearDown(self):