Skip to content

Commit 0708278

Browse files
committed
fixups
1 parent 8b357cd commit 0708278

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

pymongo/network_layer.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ def data_received(self, data: bytes) -> None:
495495
return
496496

497497
self._bytes_ready += len(data)
498-
self._buffers.append(memoryview[data])
498+
self._buffers.append(memoryview(data))
499499

500500
if not len(self._pending_reads):
501501
return
@@ -505,9 +505,6 @@ def data_received(self, data: bytes) -> None:
505505
waiter = self._pending_listeners.popleft()
506506
waiter.set_result(data)
507507

508-
def eof_received(self):
509-
self.close(OSError("connection closed"))
510-
511508
async def read(self, bytes_needed: int) -> bytes:
512509
"""Read up to the requested bytes from this connection."""
513510
# Note: all reads are "up-to" bytes_needed because we don't know if the kms_context
@@ -552,8 +549,9 @@ def _read(self, bytes_needed: int) -> memoryview:
552549
# if we didn't exhaust the buffer, read the partial data and return the buffer.
553550
if buf_size > n_remaining:
554551
output_buf[out_index : n_remaining + out_index] = buffer[:n_remaining]
552+
buffer = buffer[n_remaining:]
555553
n_remaining = 0
556-
self._buffers.appendleft(buffer[n_remaining:])
554+
self._buffers.appendleft(buffer)
557555
# otherwise exhaust the buffer.
558556
else:
559557
output_buf[out_index : out_index + buf_size] = buffer[:]

0 commit comments

Comments
 (0)