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
5 changes: 4 additions & 1 deletion pymongo/network_layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ async def _async_sendall_ssl(
total_sent += sent

async def _async_receive_ssl(
conn: _sslConn, length: int, dummy: AbstractEventLoop
conn: _sslConn, length: int, dummy: AbstractEventLoop, once: Optional[bool] = False
) -> memoryview:
mv = memoryview(bytearray(length))
total_read = 0
Expand All @@ -215,6 +215,9 @@ async def _async_receive_ssl(
while total_read < length:
try:
read = conn.recv_into(mv[total_read:])
# KMS responses update their expected size after the first batch, stop reading after one loop
if once:
return mv[:read]
if read == 0:
raise OSError("connection closed")
except BLOCKING_IO_ERRORS:
Expand Down
Loading