From: Bryan不可思议 Date: Fri, 6 Oct 2023 06:53:40 +0000 (+0000) Subject: deprecate: AsyncSession.close_all() X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=175c91f6bb64d30b713e3f990fa8b8d119e3f493;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git deprecate: AsyncSession.close_all() --- diff --git a/lib/sqlalchemy/ext/asyncio/scoping.py b/lib/sqlalchemy/ext/asyncio/scoping.py index 3e6d4fc71c..b2258f4611 100644 --- a/lib/sqlalchemy/ext/asyncio/scoping.py +++ b/lib/sqlalchemy/ext/asyncio/scoping.py @@ -1544,7 +1544,7 @@ class async_scoped_session(Generic[_AS]): return self._proxied.info @classmethod - async def close_all(self) -> None: + async def close_all(cls) -> None: r"""Close all :class:`_asyncio.AsyncSession` sessions. .. container:: class_bases @@ -1552,6 +1552,9 @@ class async_scoped_session(Generic[_AS]): Proxied for the :class:`_asyncio.AsyncSession` class on behalf of the :class:`_asyncio.scoping.async_scoped_session` class. + .. deprecated:: 2.0 The :meth:`.AsyncSession.close_all` method is deprecated and will be removed in a future release. Please refer to :func:`.session.close_all_sessions`. + + """ # noqa: E501 return await AsyncSession.close_all() diff --git a/lib/sqlalchemy/ext/asyncio/session.py b/lib/sqlalchemy/ext/asyncio/session.py index 897cc496e8..429ff6e869 100644 --- a/lib/sqlalchemy/ext/asyncio/session.py +++ b/lib/sqlalchemy/ext/asyncio/session.py @@ -1059,7 +1059,11 @@ class AsyncSession(ReversibleProxy[Session]): @classmethod async def close_all(cls) -> None: - """Close all :class:`_asyncio.AsyncSession` sessions.""" + """Close all :class:`_asyncio.AsyncSession` sessions. + + .. deprecated:: 2.0 The :meth:`.AsyncSession.close_all` method is deprecated and will be removed in a future release. Please refer to :func:`.session.close_all_sessions`. + + """ # noqa: E501 await greenlet_spawn(close_all_sessions) async def __aenter__(self: _AS) -> _AS: