Skip to content

Commit

Permalink
Cleanup CommandCursor init
Browse files Browse the repository at this point in the history
  • Loading branch information
NoahStapp committed Jun 14, 2024
1 parent c27a36a commit 3d95075
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions pymongo/asynchronous/command_cursor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down Expand Up @@ -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:
Expand Down
8 changes: 4 additions & 4 deletions pymongo/synchronous/command_cursor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 3d95075

Please sign in to comment.