Skip to content

Commit 0dd5a5c

Browse files
authored
PYTHON-5405 Use legacy wait_for_read cancellation approach on Windows (#2363)
1 parent f50ef65 commit 0dd5a5c

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

pymongo/network_layer.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,7 @@ async def _async_socket_receive(
286286

287287

288288
_PYPY = "PyPy" in sys.version
289+
_WINDOWS = sys.platform == "win32"
289290

290291

291292
def wait_for_read(conn: Connection, deadline: Optional[float]) -> None:
@@ -337,7 +338,8 @@ def receive_data(conn: Connection, length: int, deadline: Optional[float]) -> me
337338
while bytes_read < length:
338339
try:
339340
# Use the legacy wait_for_read cancellation approach on PyPy due to PYTHON-5011.
340-
if _PYPY:
341+
# also use it on Windows due to PYTHON-5405
342+
if _PYPY or _WINDOWS:
341343
wait_for_read(conn, deadline)
342344
if _csot.get_timeout() and deadline is not None:
343345
conn.set_conn_timeout(max(deadline - time.monotonic(), 0))
@@ -359,6 +361,7 @@ def receive_data(conn: Connection, length: int, deadline: Optional[float]) -> me
359361
raise _OperationCancelled("operation cancelled") from None
360362
if (
361363
_PYPY
364+
or _WINDOWS
362365
or not conn.is_sdam
363366
and deadline is not None
364367
and deadline - time.monotonic() < 0

0 commit comments

Comments
 (0)