Skip to content

Commit 24e96f0

Browse files
committed
return_exceptions=True for gather calls
1 parent 2ac4ea3 commit 24e96f0

File tree

6 files changed

+10
-6
lines changed

6 files changed

+10
-6
lines changed

pymongo/asynchronous/mongo_client.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1567,7 +1567,8 @@ async def close(self) -> None:
15671567
self._closed = True
15681568
if not _IS_SYNC:
15691569
await asyncio.gather(
1570-
*[self._topology.cleanup_monitors(), self._kill_cursors_executor.join()] # type: ignore[func-returns-value]
1570+
*[self._topology.cleanup_monitors(), self._kill_cursors_executor.join()], # type: ignore[func-returns-value]
1571+
return_exceptions=True,
15711572
)
15721573

15731574
if not _IS_SYNC:

pymongo/asynchronous/monitor.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,9 @@ def gc_safe_close(self) -> None:
190190
self.cancel_check()
191191

192192
async def join(self) -> None:
193-
await asyncio.gather(*[self._executor.join(), self._rtt_monitor.join()]) # type: ignore[func-returns-value]
193+
await asyncio.gather(
194+
*[self._executor.join(), self._rtt_monitor.join()], return_exceptions=True
195+
) # type: ignore[func-returns-value]
194196

195197
async def close(self) -> None:
196198
self.gc_safe_close()

pymongo/asynchronous/topology.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1056,7 +1056,7 @@ async def cleanup_monitors(self) -> None:
10561056
tasks.append(self._monitor_tasks.pop())
10571057
except IndexError:
10581058
pass
1059-
await asyncio.gather(*[t.join() for t in tasks]) # type: ignore[func-returns-value]
1059+
await asyncio.gather(*[t.join() for t in tasks], return_exceptions=True) # type: ignore[func-returns-value]
10601060

10611061
def __repr__(self) -> str:
10621062
msg = ""

pymongo/synchronous/mongo_client.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1561,7 +1561,8 @@ def close(self) -> None:
15611561
self._closed = True
15621562
if not _IS_SYNC:
15631563
asyncio.gather(
1564-
*[self._topology.cleanup_monitors(), self._kill_cursors_executor.join()] # type: ignore[func-returns-value]
1564+
*[self._topology.cleanup_monitors(), self._kill_cursors_executor.join()], # type: ignore[func-returns-value]
1565+
return_exceptions=True,
15651566
)
15661567

15671568
if not _IS_SYNC:

pymongo/synchronous/monitor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ def gc_safe_close(self) -> None:
190190
self.cancel_check()
191191

192192
def join(self) -> None:
193-
asyncio.gather(*[self._executor.join(), self._rtt_monitor.join()]) # type: ignore[func-returns-value]
193+
asyncio.gather(*[self._executor.join(), self._rtt_monitor.join()], return_exceptions=True) # type: ignore[func-returns-value]
194194

195195
def close(self) -> None:
196196
self.gc_safe_close()

pymongo/synchronous/topology.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1054,7 +1054,7 @@ def cleanup_monitors(self) -> None:
10541054
tasks.append(self._monitor_tasks.pop())
10551055
except IndexError:
10561056
pass
1057-
asyncio.gather(*[t.join() for t in tasks]) # type: ignore[func-returns-value]
1057+
asyncio.gather(*[t.join() for t in tasks], return_exceptions=True) # type: ignore[func-returns-value]
10581058

10591059
def __repr__(self) -> str:
10601060
msg = ""

0 commit comments

Comments
 (0)