Mercurial > vim
diff src/testdir/test_netbeans.py @ 31665:8492bbc9f533 v9.0.1165
patch 9.0.1165: tests using IPv6 sometimes fail
Commit: https://github.com/vim/vim/commit/765d82a657c5e42d5d7c88ae410e53f398c34c43
Author: James McCoy <jamessan@jamessan.com>
Date: Mon Jan 9 16:25:59 2023 +0000
patch 9.0.1165: tests using IPv6 sometimes fail
Problem: Tests using IPv6 sometimes fail.
Solution: Use getaddrinfo() and use try/catch. (James McCoy,
closes #11783)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 09 Jan 2023 17:30:07 +0100 |
parents | c8a4ad051d23 |
children |
line wrap: on
line diff
--- a/src/testdir/test_netbeans.py +++ b/src/testdir/test_netbeans.py @@ -184,8 +184,13 @@ def writePortInFile(port): if __name__ == "__main__": HOST, PORT = "localhost", 0 - server = ThreadedTCPServer((HOST, PORT), ThreadedTCPRequestHandler) - ip, port = server.server_address + addrs = socket.getaddrinfo(HOST, PORT, 0, 0, socket.IPPROTO_TCP) + # Each addr is a (family, type, proto, canonname, sockaddr) tuple + sockaddr = addrs[0][4] + ThreadedTCPServer.address_family = addrs[0][0] + + server = ThreadedTCPServer(sockaddr[0:2], ThreadedTCPRequestHandler) + ip, port = server.server_address[0:2] # Start a thread with the server. That thread will then start a new thread # for each connection. @@ -199,7 +204,7 @@ if __name__ == "__main__": # Main thread terminates, but the server continues running # until server.shutdown() is called. try: - while server_thread.isAlive(): + while server_thread.is_alive(): server_thread.join(1) except (KeyboardInterrupt, SystemExit): server.shutdown()