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__(
879
879
self ._opened = False
880
880
self ._closed = False
881
881
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
889
882
if not is_srv :
890
883
self ._init_background ()
891
884
@@ -1720,9 +1713,8 @@ async def _get_topology(self) -> Topology:
1720
1713
if not _IS_SYNC :
1721
1714
if self ._loop is None :
1722
1715
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" )
1726
1718
if not self ._opened :
1727
1719
if self ._resolve_srv_info ["is_srv" ]:
1728
1720
await self ._resolve_srv ()
Original file line number Diff line number Diff line change @@ -877,13 +877,6 @@ def __init__(
877
877
self ._opened = False
878
878
self ._closed = False
879
879
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
887
880
if not is_srv :
888
881
self ._init_background ()
889
882
@@ -1714,9 +1707,8 @@ def _get_topology(self) -> Topology:
1714
1707
if not _IS_SYNC :
1715
1708
if self ._loop is None :
1716
1709
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" )
1720
1712
if not self ._opened :
1721
1713
if self ._resolve_srv_info ["is_srv" ]:
1722
1714
self ._resolve_srv ()
You can’t perform that action at this time.
0 commit comments