From 175c91f6bb64d30b713e3f990fa8b8d119e3f493 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bryan=E4=B8=8D=E5=8F=AF=E6=80=9D=E8=AE=AE?= Date: Fri, 6 Oct 2023 06:53:40 +0000 Subject: [PATCH] deprecate: AsyncSession.close_all() --- lib/sqlalchemy/ext/asyncio/scoping.py | 5 ++++- lib/sqlalchemy/ext/asyncio/session.py | 6 +++++- 2 files changed, 9 insertions(+), 2 deletions(-) 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: -- 2.47.3