From 5aac8b7c2cecd636004f32ec5d7c5a4331fddb17 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Charles-Fran=C3=A7ois=20Natali?= Date: Thu, 29 Aug 2013 19:00:30 +0200 Subject: [PATCH] Issue #18643: Fix some test_socket failures due to large default socket buffer sizes. --- Lib/test/test_socket.py | 5 +++-- Lib/test/test_support.py | 10 ++++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/Lib/test/test_socket.py b/Lib/test/test_socket.py index 6e7218034d9c..aef9b1a95d2b 100644 --- a/Lib/test/test_socket.py +++ b/Lib/test/test_socket.py @@ -688,11 +688,12 @@ class GeneralModuleTests(unittest.TestCase): c.settimeout(1.5) with self.assertRaises(ZeroDivisionError): signal.alarm(1) - c.sendall(b"x" * (1024**2)) + c.sendall(b"x" * test_support.SOCK_MAX_SIZE) if with_timeout: signal.signal(signal.SIGALRM, ok_handler) signal.alarm(1) - self.assertRaises(socket.timeout, c.sendall, b"x" * (1024**2)) + self.assertRaises(socket.timeout, c.sendall, + b"x" * test_support.SOCK_MAX_SIZE) finally: signal.signal(signal.SIGALRM, old_alarm) c.close() diff --git a/Lib/test/test_support.py b/Lib/test/test_support.py index be867bd507e7..1f3c039b2f5d 100644 --- a/Lib/test/test_support.py +++ b/Lib/test/test_support.py @@ -411,8 +411,14 @@ def fcmp(x, y): # fuzzy comparison function # Windows limit seems to be around 512 B, and many Unix kernels have a # 64 KiB pipe buffer size or 16 * PAGE_SIZE: take a few megs to be sure. # (see issue #17835 for a discussion of this number). -PIPE_MAX_SIZE = 4 *1024 * 1024 + 1 - +PIPE_MAX_SIZE = 4 * 1024 * 1024 + 1 + +# A constant likely larger than the underlying OS socket buffer size, to make +# writes blocking. +# The socket buffer sizes can usually be tuned system-wide (e.g. through sysctl +# on Linux), or on a per-socket basis (SO_SNDBUF/SO_RCVBUF). See issue #18643 +# for a discussion of this number). +SOCK_MAX_SIZE = 16 * 1024 * 1024 + 1 try: unicode -- 2.47.3