Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e33d5b0

Browse files
committed
Merge.
2 parents 50254c5 + 5fd2642 commit e33d5b0

2 files changed

Lines changed: 12 additions & 5 deletions

File tree

Lib/test/support/__init__.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -603,8 +603,14 @@ def _is_ipv6_enabled():
603603
# Windows limit seems to be around 512 B, and many Unix kernels have a
604604
# 64 KiB pipe buffer size or 16 * PAGE_SIZE: take a few megs to be sure.
605605
# (see issue #17835 for a discussion of this number).
606-
PIPE_MAX_SIZE = 4 *1024 * 1024 + 1
607-
606+
PIPE_MAX_SIZE = 4 * 1024 * 1024 + 1
607+
608+
# A constant likely larger than the underlying OS socket buffer size, to make
609+
# writes blocking.
610+
# The socket buffer sizes can usually be tuned system-wide (e.g. through sysctl
611+
# on Linux), or on a per-socket basis (SO_SNDBUF/SO_RCVBUF). See issue #18643
612+
# for a discussion of this number).
613+
SOCK_MAX_SIZE = 16 * 1024 * 1024 + 1
608614

609615
# decorator for skipping tests on non-IEEE 754 platforms
610616
requires_IEEE_754 = unittest.skipUnless(

Lib/test/test_socket.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1210,11 +1210,12 @@ def raising_handler(*args):
12101210
c.settimeout(1.5)
12111211
with self.assertRaises(ZeroDivisionError):
12121212
signal.alarm(1)
1213-
c.sendall(b"x" * (1024**2))
1213+
c.sendall(b"x" * support.SOCK_MAX_SIZE)
12141214
if with_timeout:
12151215
signal.signal(signal.SIGALRM, ok_handler)
12161216
signal.alarm(1)
1217-
self.assertRaises(socket.timeout, c.sendall, b"x" * (1024**2))
1217+
self.assertRaises(socket.timeout, c.sendall,
1218+
b"x" * support.SOCK_MAX_SIZE)
12181219
finally:
12191220
signal.alarm(0)
12201221
signal.signal(signal.SIGALRM, old_alarm)
@@ -4047,7 +4048,7 @@ def _testWriteNonBlocking(self):
40474048
self.serv_skipped = None
40484049
self.serv_conn.setblocking(False)
40494050
# Try to saturate the socket buffer pipe with repeated large writes.
4050-
BIG = b"x" * (1024 ** 2)
4051+
BIG = b"x" * support.SOCK_MAX_SIZE
40514052
LIMIT = 10
40524053
# The first write() succeeds since a chunk of data can be buffered
40534054
n = self.write_file.write(BIG)

0 commit comments

Comments
 (0)