Skip to content

Commit 3d95075

Browse files
committed
Cleanup CommandCursor init
1 parent c27a36a commit 3d95075

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

pymongo/asynchronous/command_cursor.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ def __init__(
8181
self._explicit_session = explicit_session
8282
self._killed = self._id == 0
8383
self._comment = comment
84-
if _IS_SYNC and self._killed:
85-
self._end_session(True) # type: ignore[unused-coroutine]
84+
if self._killed:
85+
self._end_session()
8686

8787
if "ns" in cursor_info: # noqa: SIM401
8888
self._ns = cursor_info["ns"]
@@ -234,9 +234,9 @@ async def _die_lock(self) -> None:
234234
self._session = None
235235
self._sock_mgr = None
236236

237-
async def _end_session(self, synchronous: bool) -> None:
237+
def _end_session(self) -> None:
238238
if self._session and not self._explicit_session:
239-
await self._session._end_session(lock=synchronous)
239+
self._session._end_implicit_session()
240240
self._session = None
241241

242242
async def close(self) -> None:

pymongo/synchronous/command_cursor.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ def __init__(
8181
self._explicit_session = explicit_session
8282
self._killed = self._id == 0
8383
self._comment = comment
84-
if _IS_SYNC and self._killed:
85-
self._end_session(True) # type: ignore[unused-coroutine]
84+
if self._killed:
85+
self._end_session()
8686

8787
if "ns" in cursor_info: # noqa: SIM401
8888
self._ns = cursor_info["ns"]
@@ -234,9 +234,9 @@ def _die_lock(self) -> None:
234234
self._session = None
235235
self._sock_mgr = None
236236

237-
def _end_session(self, synchronous: bool) -> None:
237+
def _end_session(self) -> None:
238238
if self._session and not self._explicit_session:
239-
self._session._end_session(lock=synchronous)
239+
self._session._end_implicit_session()
240240
self._session = None
241241

242242
def close(self) -> None:

0 commit comments

Comments
 (0)