Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion tests/unit/fake_broker.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,17 @@ def stop(self) -> None:
self._thread.join(0.5)

def drop_connection(self) -> None:
"""Close the socket abruptly, without any ``close`` performative."""
"""Close the socket abruptly, without any ``close`` performative.

``shutdown()`` first, same as :meth:`stop`: closing a socket from one
thread doesn't reliably unblock another thread of this same process
blocked in ``recv()`` on it (``_run`` sits in exactly that state) —
Linux defers the actual teardown, and thus EOF on the peer, until
that blocking call returns on its own, which macOS does not.
"""
self._stop.set()
with contextlib.suppress(OSError):
self._sock.shutdown(socket.SHUT_RDWR)
self._sock.close()

# --- writing --------------------------------------------------------
Expand Down