Skip to content

Commit 69bcb4e

Browse files
committed
PYTHON-4324 Wrap receive_data errors in pymongo errors
1 parent 2f841a2 commit 69bcb4e

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

pymongo/asynchronous/pool.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,10 @@ async def complete_pending(self) -> None:
216216
# TODO: respect deadline
217217
await self.receive_message(None, True)
218218
else:
219-
network_layer.receive_data(self, self.pending_bytes, deadline) # type:ignore[call-arg]
219+
try:
220+
network_layer.receive_data(self, self.pending_bytes, deadline) # type:ignore[call-arg]
221+
except BaseException as error:
222+
await self._raise_connection_failure(error)
220223
self.pending_response = False
221224
self.pending_bytes = 0
222225
self.pending_deadline = 0.0

pymongo/synchronous/pool.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,10 @@ def complete_pending(self) -> None:
216216
# TODO: respect deadline
217217
self.receive_message(None, True)
218218
else:
219-
network_layer.receive_data(self, self.pending_bytes, deadline) # type:ignore[call-arg]
219+
try:
220+
network_layer.receive_data(self, self.pending_bytes, deadline) # type:ignore[call-arg]
221+
except BaseException as error:
222+
self._raise_connection_failure(error)
220223
self.pending_response = False
221224
self.pending_bytes = 0
222225
self.pending_deadline = 0.0

0 commit comments

Comments
 (0)