diff options
Diffstat (limited to 'Lib/test/test_socketserver.py')
-rw-r--r-- | Lib/test/test_socketserver.py | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/Lib/test/test_socketserver.py b/Lib/test/test_socketserver.py index 062be65..da936a4 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 @@ -81,9 +82,13 @@ class ServerThread(threading.Thread): svr = svrcls(self.__addr, self.__hdlrcls) # pull the address out of the server in case it changed # this can happen if another process is using the port - addr = getattr(svr, 'server_address') + addr = svr.server_address if addr: self.__addr = addr + 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") @@ -136,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") |