File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2268,15 +2268,14 @@ async def _tmp_session(
22682268 self , session : Optional [client_session .AsyncClientSession ]
22692269 ) -> AsyncGenerator [Optional [client_session .AsyncClientSession ], None ]:
22702270 """If provided session is None, lend a temporary session."""
2271+ if session is not None and not isinstance (session , client_session .AsyncClientSession ):
2272+ raise ValueError (
2273+ f"'session' argument must be an AsyncClientSession or None, not { type (session )} "
2274+ )
22712275
22722276 # Check for a bound session. If one exists, treat it as an explicitly passed session.
22732277 session = session or self ._get_bound_session ()
2274-
2275- if session is not None :
2276- if not isinstance (session , client_session .AsyncClientSession ):
2277- raise ValueError (
2278- f"'session' argument must be an AsyncClientSession or None, not { type (session )} "
2279- )
2278+ if session :
22802279 # Don't call end_session.
22812280 yield session
22822281 return
Original file line number Diff line number Diff line change @@ -2264,15 +2264,14 @@ def _tmp_session(
22642264 self , session : Optional [client_session .ClientSession ]
22652265 ) -> Generator [Optional [client_session .ClientSession ], None ]:
22662266 """If provided session is None, lend a temporary session."""
2267+ if session is not None and not isinstance (session , client_session .ClientSession ):
2268+ raise ValueError (
2269+ f"'session' argument must be a ClientSession or None, not { type (session )} "
2270+ )
22672271
22682272 # Check for a bound session. If one exists, treat it as an explicitly passed session.
22692273 session = session or self ._get_bound_session ()
2270-
2271- if session is not None :
2272- if not isinstance (session , client_session .ClientSession ):
2273- raise ValueError (
2274- f"'session' argument must be a ClientSession or None, not { type (session )} "
2275- )
2274+ if session :
22762275 # Don't call end_session.
22772276 yield session
22782277 return
Original file line number Diff line number Diff line change @@ -877,6 +877,8 @@ async def test_nested_session_binding(self):
877877
878878 session1 = self .client .start_session ()
879879 session2 = self .client .start_session ()
880+ session1 ._materialize ()
881+ session2 ._materialize ()
880882 try :
881883 self .listener .reset ()
882884 # Uses implicit session
Original file line number Diff line number Diff line change @@ -877,6 +877,8 @@ def test_nested_session_binding(self):
877877
878878 session1 = self .client .start_session ()
879879 session2 = self .client .start_session ()
880+ session1 ._materialize ()
881+ session2 ._materialize ()
880882 try :
881883 self .listener .reset ()
882884 # Uses implicit session
You can’t perform that action at this time.
0 commit comments