changeset: 85449:2de7fc69d2d4 branch: 2.7 parent: 85411:187a678c6033 user: Charles-François Natali date: Thu Aug 29 19:00:30 2013 +0200 files: Lib/test/test_socket.py Lib/test/test_support.py description: Issue #18643: Fix some test_socket failures due to large default socket buffer sizes. diff -r 187a678c6033 -r 2de7fc69d2d4 Lib/test/test_socket.py --- a/Lib/test/test_socket.py Mon Aug 26 14:00:39 2013 +0300 +++ b/Lib/test/test_socket.py Thu Aug 29 19:00:30 2013 +0200 @@ -688,11 +688,12 @@ 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 -r 187a678c6033 -r 2de7fc69d2d4 Lib/test/test_support.py --- a/Lib/test/test_support.py Mon Aug 26 14:00:39 2013 +0300 +++ b/Lib/test/test_support.py Thu Aug 29 19:00:30 2013 +0200 @@ -411,8 +411,14 @@ # 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