File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -601,8 +601,14 @@ def _is_ipv6_enabled():
601601# Windows limit seems to be around 512 B, and many Unix kernels have a
602602# 64 KiB pipe buffer size or 16 * PAGE_SIZE: take a few megs to be sure.
603603# (see issue #17835 for a discussion of this number).
604- PIPE_MAX_SIZE = 4 * 1024 * 1024 + 1
605-
604+ PIPE_MAX_SIZE = 4 * 1024 * 1024 + 1
605+
606+ # A constant likely larger than the underlying OS socket buffer size, to make
607+ # writes blocking.
608+ # The socket buffer sizes can usually be tuned system-wide (e.g. through sysctl
609+ # on Linux), or on a per-socket basis (SO_SNDBUF/SO_RCVBUF). See issue #18643
610+ # for a discussion of this number).
611+ SOCK_MAX_SIZE = 16 * 1024 * 1024 + 1
606612
607613# decorator for skipping tests on non-IEEE 754 platforms
608614requires_IEEE_754 = unittest .skipUnless (
Original file line number Diff line number Diff 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 )
You can’t perform that action at this time.
0 commit comments