Skip to content

Commit b7232db

Browse files
committed
Address review
1 parent 4f0c8e4 commit b7232db

File tree

4 files changed

+16
-8
lines changed

4 files changed

+16
-8
lines changed

pymongo/asynchronous/pool.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -863,7 +863,8 @@ async def _reset(
863863
if close:
864864
if not _IS_SYNC:
865865
await asyncio.gather(
866-
*[conn.close_conn(ConnectionClosedReason.POOL_CLOSED) for conn in sockets]
866+
*[conn.close_conn(ConnectionClosedReason.POOL_CLOSED) for conn in sockets],
867+
return_exceptions=True,
867868
)
868869
else:
869870
for conn in sockets:
@@ -899,7 +900,8 @@ async def _reset(
899900
)
900901
if not _IS_SYNC:
901902
await asyncio.gather(
902-
*[conn.close_conn(ConnectionClosedReason.STALE) for conn in sockets]
903+
*[conn.close_conn(ConnectionClosedReason.STALE) for conn in sockets],
904+
return_exceptions=True,
903905
)
904906
else:
905907
for conn in sockets:
@@ -951,7 +953,8 @@ async def remove_stale_sockets(self, reference_generation: int) -> None:
951953
close_conns.append(self.conns.pop())
952954
if not _IS_SYNC:
953955
await asyncio.gather(
954-
*[conn.close_conn(ConnectionClosedReason.IDLE) for conn in close_conns]
956+
*[conn.close_conn(ConnectionClosedReason.IDLE) for conn in close_conns],
957+
return_exceptions=True,
955958
)
956959
else:
957960
for conn in close_conns:

pymongo/asynchronous/topology.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,7 @@ async def on_change(
552552
if self._opened and self._description.has_server(server_description.address):
553553
await self._process_change(server_description, reset_pool, interrupt_connections)
554554
# Clear the pool from a failed heartbeat, done outside the lock to avoid blocking on connection close.
555-
if self._opened and self._description.has_server(server_description.address) and reset_pool:
555+
if reset_pool:
556556
server = self._servers.get(server_description.address)
557557
if server:
558558
await server.pool.reset(interrupt_connections=interrupt_connections)

pymongo/synchronous/pool.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -861,7 +861,8 @@ def _reset(
861861
if close:
862862
if not _IS_SYNC:
863863
asyncio.gather(
864-
*[conn.close_conn(ConnectionClosedReason.POOL_CLOSED) for conn in sockets]
864+
*[conn.close_conn(ConnectionClosedReason.POOL_CLOSED) for conn in sockets],
865+
return_exceptions=True,
865866
)
866867
else:
867868
for conn in sockets:
@@ -896,7 +897,10 @@ def _reset(
896897
serviceId=service_id,
897898
)
898899
if not _IS_SYNC:
899-
asyncio.gather(*[conn.close_conn(ConnectionClosedReason.STALE) for conn in sockets])
900+
asyncio.gather(
901+
*[conn.close_conn(ConnectionClosedReason.STALE) for conn in sockets],
902+
return_exceptions=True,
903+
)
900904
else:
901905
for conn in sockets:
902906
conn.close_conn(ConnectionClosedReason.STALE)
@@ -945,7 +949,8 @@ def remove_stale_sockets(self, reference_generation: int) -> None:
945949
close_conns.append(self.conns.pop())
946950
if not _IS_SYNC:
947951
asyncio.gather(
948-
*[conn.close_conn(ConnectionClosedReason.IDLE) for conn in close_conns]
952+
*[conn.close_conn(ConnectionClosedReason.IDLE) for conn in close_conns],
953+
return_exceptions=True,
949954
)
950955
else:
951956
for conn in close_conns:

pymongo/synchronous/topology.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,7 @@ def on_change(
552552
if self._opened and self._description.has_server(server_description.address):
553553
self._process_change(server_description, reset_pool, interrupt_connections)
554554
# Clear the pool from a failed heartbeat, done outside the lock to avoid blocking on connection close.
555-
if self._opened and self._description.has_server(server_description.address) and reset_pool:
555+
if reset_pool:
556556
server = self._servers.get(server_description.address)
557557
if server:
558558
server.pool.reset(interrupt_connections=interrupt_connections)

0 commit comments

Comments
 (0)