From 605fc9bceb6e145e2bba6faa55061b39350c17ff Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bryan=E4=B8=8D=E5=8F=AF=E6=80=9D=E8=AE=AE?= Date: Sat, 14 Oct 2023 09:08:30 +0000 Subject: [PATCH] Revert "deprecate: remove async_scoped_session.close_all()" This reverts commit 63e92e6e4b034f2d569679d9b80fb9f93f8e4a81. --- lib/sqlalchemy/ext/asyncio/scoping.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/sqlalchemy/ext/asyncio/scoping.py b/lib/sqlalchemy/ext/asyncio/scoping.py index 33c9b35900..0c19acb979 100644 --- a/lib/sqlalchemy/ext/asyncio/scoping.py +++ b/lib/sqlalchemy/ext/asyncio/scoping.py @@ -67,7 +67,7 @@ _T = TypeVar("_T", bound=Any) AsyncSession, ":class:`_asyncio.AsyncSession`", ":class:`_asyncio.scoping.async_scoped_session`", - classmethods=["object_session", "identity_key"], + classmethods=["close_all", "object_session", "identity_key"], methods=[ "__contains__", "__iter__", @@ -1543,6 +1543,21 @@ class async_scoped_session(Generic[_AS]): return self._proxied.info + @classmethod + async def close_all(cls) -> None: + r"""Close all :class:`_asyncio.AsyncSession` sessions. + + .. container:: class_bases + + 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() + @classmethod def object_session(cls, instance: object) -> Optional[Session]: r"""Return the :class:`.Session` to which an object belongs. -- 2.47.3