Skip to content

Commit 13537cb

Browse files
committed
wip
1 parent 0a43477 commit 13537cb

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

pymongo/asynchronous/encryption.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ async def kms_request(self, kms_context: MongoCryptKmsContext) -> None:
213213
address, exc, msg_prefix=msg_prefix, timeout_details=_get_timeout_details(opts)
214214
)
215215
finally:
216-
conn.close_conn(None)
216+
await conn.close_conn(None)
217217
except MongoCryptError:
218218
raise # Propagate MongoCryptError errors directly.
219219
except Exception as exc:

pymongo/network_layer.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,12 @@ def connection_made(self, transport: BaseTransport) -> None:
503503

504504
async def read(self, bytes_needed: int) -> bytes:
505505
"""Read the requested bytes from this connection."""
506+
if self.transport:
507+
try:
508+
self.transport.resume_reading()
509+
# Known bug in SSL Protocols, fixed in Python 3.11: https://github.com/python/cpython/issues/89322
510+
except AttributeError:
511+
raise OSError("connection is already closed") from None
506512
if self.transport and self.transport.is_closing():
507513
raise OSError("connection is already closed")
508514
self._pending_reads.append(bytes_needed)
@@ -552,11 +558,11 @@ def buffer_updated(self, nbytes: int) -> None:
552558
buffer_remaining = len(buffer.buffer) - buffer.start_index
553559
# if we didn't exhaust the buffer, read the partial data and put it back.
554560
if buffer_remaining > n_remaining:
555-
n_remaining = 0
556561
output_buf[out_index : n_remaining + out_index] = buffer.buffer[
557562
buffer.start_index : buffer.start_index + n_remaining
558563
]
559564
buffer.start_index += n_remaining
565+
n_remaining = 0
560566
self._buffers.appendleft(buffer)
561567
# otherwise exhaust the buffer and return it to the pool.
562568
else:

0 commit comments

Comments
 (0)