From 3d95075802da0e3c4197f3b205a2a5293d6017c3 Mon Sep 17 00:00:00 2001 From: Noah Stapp Date: Fri, 14 Jun 2024 16:49:04 -0700 Subject: [PATCH] Cleanup CommandCursor init --- pymongo/asynchronous/command_cursor.py | 8 ++++---- pymongo/synchronous/command_cursor.py | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/pymongo/asynchronous/command_cursor.py b/pymongo/asynchronous/command_cursor.py index 7470076c66..000df160d4 100644 --- a/pymongo/asynchronous/command_cursor.py +++ b/pymongo/asynchronous/command_cursor.py @@ -81,8 +81,8 @@ def __init__( self._explicit_session = explicit_session self._killed = self._id == 0 self._comment = comment - if _IS_SYNC and self._killed: - self._end_session(True) # type: ignore[unused-coroutine] + if self._killed: + self._end_session() if "ns" in cursor_info: # noqa: SIM401 self._ns = cursor_info["ns"] @@ -234,9 +234,9 @@ async def _die_lock(self) -> None: self._session = None self._sock_mgr = None - async def _end_session(self, synchronous: bool) -> None: + def _end_session(self) -> None: if self._session and not self._explicit_session: - await self._session._end_session(lock=synchronous) + self._session._end_implicit_session() self._session = None async def close(self) -> None: diff --git a/pymongo/synchronous/command_cursor.py b/pymongo/synchronous/command_cursor.py index 04a9c2ab35..acd658d69a 100644 --- a/pymongo/synchronous/command_cursor.py +++ b/pymongo/synchronous/command_cursor.py @@ -81,8 +81,8 @@ def __init__( self._explicit_session = explicit_session self._killed = self._id == 0 self._comment = comment - if _IS_SYNC and self._killed: - self._end_session(True) # type: ignore[unused-coroutine] + if self._killed: + self._end_session() if "ns" in cursor_info: # noqa: SIM401 self._ns = cursor_info["ns"] @@ -234,9 +234,9 @@ def _die_lock(self) -> None: self._session = None self._sock_mgr = None - def _end_session(self, synchronous: bool) -> None: + def _end_session(self) -> None: if self._session and not self._explicit_session: - self._session._end_session(lock=synchronous) + self._session._end_implicit_session() self._session = None def close(self) -> None: