From b227e3cb82c8d42ea27790d615ecafe12528d3bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= Date: Wed, 28 Jul 2021 18:23:08 +0200 Subject: [PATCH] Fix creating non-listening sockets in tests on some platforms (#5890) Fix the listen() invocation for the test server not to pass a backlog value of zero. The value of zero means no backlog which effectively means that the socket can not accept any connections. This does not matter for the majority of platforms since the value is only advisory and the platform tends to go with a bigger backlog anyway. However, a few platforms (e.g. alpha or riscv Linux) do take the value literally, and therefore the tests fail since they are unable to connect to the server. --- tests/testserver/server.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/testserver/server.py b/tests/testserver/server.py index 132221f7..c4587eef 100644 --- a/tests/testserver/server.py +++ b/tests/testserver/server.py @@ -78,7 +78,9 @@ class Server(threading.Thread): def _create_socket_and_bind(self): sock = socket.socket() sock.bind((self.host, self.port)) - sock.listen(0) + # NB: when Python 2.7 is no longer supported, the argument + # can be removed to use a default backlog size + sock.listen(5) return sock def _close_server_sock_ignore_errors(self):