diff options
author | Guido van Rossum <guido@python.org> | 2007-04-04 17:43:02 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2007-04-04 17:43:02 (GMT) |
commit | b1bb01e2f6a74814d347c295c625b6455c253857 (patch) | |
tree | 7a6d42c6156b7d757bdc7e7110a42864b78bc362 /Lib | |
parent | 06c6579036a193c84bdc1f8c7de92680f8c13e5d (diff) | |
download | cpython-b1bb01e2f6a74814d347c295c625b6455c253857.zip cpython-b1bb01e2f6a74814d347c295c625b6455c253857.tar.gz cpython-b1bb01e2f6a74814d347c295c625b6455c253857.tar.bz2 |
Fix a race condition in this test -- instead of assuming that it will take
the test server thread at most 0.5 seconds to get ready, use an event
variable.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_socketserver.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/Lib/test/test_socketserver.py b/Lib/test/test_socketserver.py index 9a67a35..bfcdf98 100644 --- a/Lib/test/test_socketserver.py +++ b/Lib/test/test_socketserver.py @@ -74,6 +74,7 @@ class ServerThread(threading.Thread): self.__addr = addr self.__svrcls = svrcls self.__hdlrcls = hdlrcls + self.ready = threading.Event() def run(self): class svrcls(MyMixinServer, self.__svrcls): pass @@ -87,6 +88,7 @@ class ServerThread(threading.Thread): if self.__addr != svr.socket.getsockname(): raise RuntimeError('server_address was %s, expected %s' % (self.__addr, svr.socket.getsockname())) + self.ready.set() if verbose: print "thread: serving three times" svr.serve_a_few() if verbose: print "thread: done" @@ -139,7 +141,9 @@ def testloop(proto, servers, hdlrcls, testfunc): t.start() if verbose: print "server running" for i in range(NREQ): - time.sleep(DELAY) + t.ready.wait(10*DELAY) + if not t.ready.isSet(): + raise RuntimeError("Server not ready within a reasonable time") if verbose: print "test client", i testfunc(proto, addr) if verbose: print "waiting for server" |