From: semen603089 Date: Sat, 29 Jul 2023 00:14:21 +0000 (+0300) Subject: changelog file, docstrings X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b32ba12cb4120d74746ea14e6ea336acf5a4abc8;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git changelog file, docstrings --- diff --git a/doc/build/changelog/unreleased_20/9698.rst b/doc/build/changelog/unreleased_20/9698.rst new file mode 100644 index 0000000000..0cf1658627 --- /dev/null +++ b/doc/build/changelog/unreleased_20/9698.rst @@ -0,0 +1,9 @@ +.. change:: + :tags: feature, engine + :tickets: 9698 + + :func:`.aclose` have been added to :class:`_asyncio.AsyncConnection` + and :class:`_asyncio.AsyncSession`. + :func:`.aclose` is a synonym for :func:`.close` + that is compatible with context managers such as ``@contextlib.aclosing`` + Patch by Grigoriev Semyon. \ No newline at end of file diff --git a/lib/sqlalchemy/ext/asyncio/engine.py b/lib/sqlalchemy/ext/asyncio/engine.py index 08e10c6332..e758e460b0 100644 --- a/lib/sqlalchemy/ext/asyncio/engine.py +++ b/lib/sqlalchemy/ext/asyncio/engine.py @@ -477,7 +477,13 @@ class AsyncConnection( await greenlet_spawn(self._proxied.close) async def aclose(self) -> None: - """Call the close() method of :class:`_asyncio.AsyncConnection`""" + """This method is a synonym for :func:`.close` + + This method is needed for compatibility with context managers, + such as ``@contextlib.aclosing`` + + .. versionadded:: 2.0.20 + """ await self.close() async def exec_driver_sql( diff --git a/lib/sqlalchemy/ext/asyncio/session.py b/lib/sqlalchemy/ext/asyncio/session.py index 26d0fe6445..fb96010fd7 100644 --- a/lib/sqlalchemy/ext/asyncio/session.py +++ b/lib/sqlalchemy/ext/asyncio/session.py @@ -974,7 +974,13 @@ class AsyncSession(ReversibleProxy[Session]): await greenlet_spawn(self.sync_session.close) async def aclose(self) -> None: - """Call the close() method of :class:`_asyncio.AsyncSession`""" + """This method is a synonym for :func:`.close` + + This method is needed for compatibility with context managers, + such as ``@contextlib.aclosing`` + + .. versionadded:: 2.0.20 + """ await self.close() async def invalidate(self) -> None: