Skip to content

Commit d73aab1

Browse files
committed
Correctly pause and resume reading
1 parent 1eccc12 commit d73aab1

File tree

5 files changed

+3
-8
lines changed

5 files changed

+3
-8
lines changed

pymongo/network_layer.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,9 +193,11 @@ async def write(self, message: bytes):
193193
raise OSError("Connection is closed")
194194
self.transport.write(message)
195195
await self._drain_helper()
196+
self.transport.resume_reading()
196197

197198
async def read(self, request_id: Optional[int], max_message_size: int, debug: bool = False):
198199
"""Read a single MongoDB Wire Protocol message from this connection."""
200+
self.transport.resume_reading()
199201
if self._done_messages:
200202
message = await self._done_messages.popleft()
201203
else:
@@ -297,6 +299,7 @@ def buffer_updated(self, nbytes: int):
297299
self._length -= extra
298300
self._expecting_header = True
299301
self.buffer_updated(extra)
302+
self.transport.pause_reading()
300303

301304
def process_header(self):
302305
"""Unpack a MongoDB Wire Protocol header."""

test/asynchronous/test_collection.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1792,8 +1792,6 @@ async def test_cursor_timeout(self):
17921792
await self.db.test.find(no_cursor_timeout=True).to_list()
17931793
await self.db.test.find(no_cursor_timeout=False).to_list()
17941794

1795-
# TODO: fix exhaust cursor + batch_size
1796-
@async_client_context.require_sync
17971795
async def test_exhaust(self):
17981796
if await async_is_mongos(self.db.client):
17991797
with self.assertRaises(InvalidOperation):

test/asynchronous/test_monitoring.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -421,8 +421,6 @@ async def test_not_primary_error(self):
421421
self.assertTrue(isinstance(failed.duration_micros, int))
422422
self.assertEqual(error, failed.failure)
423423

424-
# TODO: fix exhaust cursor + batch_size
425-
@async_client_context.require_sync
426424
@async_client_context.require_no_mongos
427425
async def test_exhaust(self):
428426
await self.client.pymongo_test.test.drop()

test/test_collection.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1774,8 +1774,6 @@ def test_cursor_timeout(self):
17741774
self.db.test.find(no_cursor_timeout=True).to_list()
17751775
self.db.test.find(no_cursor_timeout=False).to_list()
17761776

1777-
# TODO: fix exhaust cursor + batch_size
1778-
@client_context.require_sync
17791777
def test_exhaust(self):
17801778
if is_mongos(self.db.client):
17811779
with self.assertRaises(InvalidOperation):

test/test_monitoring.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -419,8 +419,6 @@ def test_not_primary_error(self):
419419
self.assertTrue(isinstance(failed.duration_micros, int))
420420
self.assertEqual(error, failed.failure)
421421

422-
# TODO: fix exhaust cursor + batch_size
423-
@client_context.require_sync
424422
@client_context.require_no_mongos
425423
def test_exhaust(self):
426424
self.client.pymongo_test.test.drop()

0 commit comments

Comments
 (0)