Skip to content

Commit 76da142

Browse files
committed
More explanatory message
1 parent 06eaa6a commit 76da142

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

pymongo/asynchronous/mongo_client.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1714,7 +1714,9 @@ async def _get_topology(self) -> Topology:
17141714
if self._loop is None:
17151715
self._loop = asyncio.get_running_loop()
17161716
elif self._loop != asyncio.get_running_loop():
1717-
raise RuntimeError("Cannot use AsyncMongoClient in different event loop")
1717+
raise RuntimeError(
1718+
"Cannot use AsyncMongoClient in different event loop. AsyncMongoClient uses low-level asyncio APIs that bind it to the event loop it was created on."
1719+
)
17181720
if not self._opened:
17191721
if self._resolve_srv_info["is_srv"]:
17201722
await self._resolve_srv()

pymongo/synchronous/mongo_client.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1708,7 +1708,9 @@ def _get_topology(self) -> Topology:
17081708
if self._loop is None:
17091709
self._loop = asyncio.get_running_loop()
17101710
elif self._loop != asyncio.get_running_loop():
1711-
raise RuntimeError("Cannot use MongoClient in different event loop")
1711+
raise RuntimeError(
1712+
"Cannot use MongoClient in different event loop. MongoClient uses low-level asyncio APIs that bind it to the event loop it was created on."
1713+
)
17121714
if not self._opened:
17131715
if self._resolve_srv_info["is_srv"]:
17141716
self._resolve_srv()

0 commit comments

Comments
 (0)