File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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
610616requires_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