File tree Expand file tree Collapse file tree 2 files changed +4
-20
lines changed Expand file tree Collapse file tree 2 files changed +4
-20
lines changed Original file line number Diff line number Diff line change @@ -879,13 +879,6 @@ def __init__(
879879 self ._opened = False
880880 self ._closed = False
881881 self ._loop : Optional [asyncio .AbstractEventLoop ] = None
882- if not _IS_SYNC :
883- # Check if the client was created within a running event loop.
884- try :
885- self ._loop = asyncio .get_running_loop ()
886- # It wasn't, so the loop will be stored during the first performed operation
887- except RuntimeError :
888- pass
889882 if not is_srv :
890883 self ._init_background ()
891884
@@ -1720,9 +1713,8 @@ async def _get_topology(self) -> Topology:
17201713 if not _IS_SYNC :
17211714 if self ._loop is None :
17221715 self ._loop = asyncio .get_running_loop ()
1723- else :
1724- if self ._loop != asyncio .get_running_loop ():
1725- raise RuntimeError ("Cannot use AsyncMongoClient in different event loop" )
1716+ elif self ._loop != asyncio .get_running_loop ():
1717+ raise RuntimeError ("Cannot use AsyncMongoClient in different event loop" )
17261718 if not self ._opened :
17271719 if self ._resolve_srv_info ["is_srv" ]:
17281720 await self ._resolve_srv ()
Original file line number Diff line number Diff line change @@ -877,13 +877,6 @@ def __init__(
877877 self ._opened = False
878878 self ._closed = False
879879 self ._loop : Optional [asyncio .AbstractEventLoop ] = None
880- if not _IS_SYNC :
881- # Check if the client was created within a running event loop.
882- try :
883- self ._loop = asyncio .get_running_loop ()
884- # It wasn't, so the loop will be stored during the first performed operation
885- except RuntimeError :
886- pass
887880 if not is_srv :
888881 self ._init_background ()
889882
@@ -1714,9 +1707,8 @@ def _get_topology(self) -> Topology:
17141707 if not _IS_SYNC :
17151708 if self ._loop is None :
17161709 self ._loop = asyncio .get_running_loop ()
1717- else :
1718- if self ._loop != asyncio .get_running_loop ():
1719- raise RuntimeError ("Cannot use MongoClient in different event loop" )
1710+ elif self ._loop != asyncio .get_running_loop ():
1711+ raise RuntimeError ("Cannot use MongoClient in different event loop" )
17201712 if not self ._opened :
17211713 if self ._resolve_srv_info ["is_srv" ]:
17221714 self ._resolve_srv ()
You can’t perform that action at this time.
0 commit comments