Skip to content

Commit a5db5d8

Browse files
alexclaude
andcommitted
Fix test_wantWriteError failure on macOS
Use Unix domain sockets instead of TCP loopback. On macOS, TCP loopback aggressively auto-tunes buffer sizes and drains the send buffer into the peer's receive buffer nearly instantly, so the send buffer won't stay full long enough for do_handshake() to observe it, resulting in WantReadError instead of the expected WantWriteError. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent f46314f commit a5db5d8

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

tests/test_ssl.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,15 @@
3030
from socket import (
3131
AF_INET,
3232
AF_INET6,
33+
AF_UNIX,
3334
MSG_PEEK,
3435
SHUT_RDWR,
3536
SO_RCVBUF,
3637
SO_SNDBUF,
3738
SOL_SOCKET,
3839
gaierror,
3940
socket,
41+
socketpair,
4042
)
4143
from sys import getfilesystemencoding, platform
4244
from weakref import ref
@@ -3070,7 +3072,14 @@ def test_wantWriteError(self) -> None:
30703072
`OpenSSL.SSL.WantWriteError` if writing to the connection's BIO
30713073
fail indicating a should-write state.
30723074
"""
3073-
client_socket, _ = socket_pair()
3075+
# Use Unix domain sockets rather than TCP loopback. On macOS,
3076+
# TCP loopback aggressively auto-tunes buffer sizes and drains
3077+
# the send buffer into the peer's receive buffer nearly
3078+
# instantly, so the send buffer won't stay full long enough
3079+
# for do_handshake() to observe it.
3080+
client_socket, peer = socketpair(AF_UNIX)
3081+
client_socket.setblocking(False)
3082+
peer.setblocking(False)
30743083
# Fill up the client's send buffer so Connection won't be able to write
30753084
# anything. Start by sending larger chunks (Windows Socket I/O is slow)
30763085
# and continue by writing a single byte at a time so we can be sure we

0 commit comments

Comments
 (0)