Skip to content

Commit fe049ad

Browse files
authored
Merge pull request #20 from ydb-platform/fix_async_cursor_close
make async cursor close() sync
2 parents 5c93366 + 1c3e2c3 commit fe049ad

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

tests/test_cursors.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ async def async_cursor(
213213
request_settings=ydb.BaseRequestSettings(),
214214
)
215215
yield cursor
216-
await greenlet_spawn(cursor.close)
216+
cursor.close()
217217

218218
@pytest.mark.asyncio
219219
async def test_cursor_fetch_one(self, async_cursor: AsyncCursor) -> None:

ydb_dbapi/cursors.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,6 @@ def close(self) -> None:
350350
if self._state == CursorStatus.closed:
351351
return
352352

353-
self._scroll_stream()
354353
self._state = CursorStatus.closed
355354

356355
def __enter__(self) -> Self:
@@ -527,11 +526,10 @@ async def _scroll_stream(self, replace_current: bool = True) -> None:
527526

528527
self._state = CursorStatus.finished
529528

530-
async def close(self) -> None:
529+
def close(self) -> None:
531530
if self._state == CursorStatus.closed:
532531
return
533532

534-
await self._scroll_stream()
535533
self._state = CursorStatus.closed
536534

537535
async def __aenter__(self) -> Self:
@@ -543,4 +541,4 @@ async def __aexit__(
543541
exc: BaseException | None,
544542
tb: object,
545543
) -> None:
546-
await self.close()
544+
self.close()

0 commit comments

Comments
 (0)