Skip to content

Commit ded90b0

Browse files
committed
handle another edge case
1 parent a033c58 commit ded90b0

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

pymongo/network_layer.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -338,8 +338,11 @@ async def read(self, request_id: Optional[int], max_message_size: int) -> tuple[
338338
if self._done_messages:
339339
message = await self._done_messages.popleft()
340340
else:
341-
if self._closing_exception:
342-
raise self._closing_exception
341+
if self._closed.done():
342+
if self._closing_exception:
343+
raise self._closing_exception
344+
else:
345+
raise OSError("connection closed")
343346
read_waiter = asyncio.get_running_loop().create_future()
344347
self._pending_messages.append(read_waiter)
345348
try:

0 commit comments

Comments
 (0)