From 658cae9fad87284a09b6170135a87c5510e019ae Mon Sep 17 00:00:00 2001 From: Michal Nowak Date: Fri, 9 Sep 2022 16:41:00 +0200 Subject: [PATCH] Bump socket.create_connection() timeout to 10 seconds The tcp Pytest on OpenBSD fairly reliably fails when receive_tcp() on a socket is attempted: > (response, rtime) = dns.query.receive_tcp(sock, timeout()) tests-tcp.py:50: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/local/lib/python3.9/site-packages/dns/query.py:659: in receive_tcp ldata = _net_read(sock, 2, expiration) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ sock = count = 2, expiration = 1662719959.8106785 def _net_read(sock, count, expiration): """Read the specified number of bytes from sock. Keep trying until we either get the desired amount, or we hit EOF. A Timeout exception will be raised if the operation is not completed by the expiration time. """ s = b'' while count > 0: try: > n = sock.recv(count) E socket.timeout: timed out This is because the socket is already closed. Bump the socket connection timeout to 10 seconds. --- bin/tests/system/tcp/tests-tcp.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/tests/system/tcp/tests-tcp.py b/bin/tests/system/tcp/tests-tcp.py index b38e1de688..38343d2cf4 100644 --- a/bin/tests/system/tcp/tests-tcp.py +++ b/bin/tests/system/tcp/tests-tcp.py @@ -37,7 +37,7 @@ def timeout(): def create_socket(host, port): - sock = socket.create_connection((host, port), timeout=1) + sock = socket.create_connection((host, port), timeout=10) sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, True) return sock