Skip to content

Commit a62ade8

Browse files
authored
PYTHON-4874 - Add KMS support for async Windows (mongodb#1939)
1 parent 8ce21bc commit a62ade8

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
@@ -205,7 +205,7 @@ async def _async_sendall_ssl(
205205
total_sent += sent
206206

207207
async def _async_receive_ssl(
208-
conn: _sslConn, length: int, dummy: AbstractEventLoop
208+
conn: _sslConn, length: int, dummy: AbstractEventLoop, once: Optional[bool] = False
209209
) -> memoryview:
210210
mv = memoryview(bytearray(length))
211211
total_read = 0
@@ -215,6 +215,9 @@ async def _async_receive_ssl(
215215
while total_read < length:
216216
try:
217217
read = conn.recv_into(mv[total_read:])
218+
# KMS responses update their expected size after the first batch, stop reading after one loop
219+
if once:
220+
return mv[:read]
218221
if read == 0:
219222
raise OSError("connection closed")
220223
except BLOCKING_IO_ERRORS:

0 commit comments

Comments
 (0)