diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2021-05-24 09:59:17 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2021-05-24 09:59:17 -0400 |
commit | fd3f98ee38b496916122d1a9a29b02d59ca671f9 (patch) | |
tree | 30f0523afe8623e5c2048a2904175d2f291864fe /lib/sqlalchemy/ext/asyncio/session.py | |
parent | b2ab2bbf4faf508b3fa5749969019203a702786f (diff) | |
download | sqlalchemy-fd3f98ee38b496916122d1a9a29b02d59ca671f9.tar.gz |
Clarify close for sync / async session
Add seealso links from Session.close() and AsyncSession.close()
to narrative description, clarify in both places what the method
does and does not do.
Change-Id: Ib804753a86b4761e5f198c52121e8433c851cbc4
References: #6528
Diffstat (limited to 'lib/sqlalchemy/ext/asyncio/session.py')
-rw-r--r-- | lib/sqlalchemy/ext/asyncio/session.py | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/lib/sqlalchemy/ext/asyncio/session.py b/lib/sqlalchemy/ext/asyncio/session.py index 8d19819b0..343465f37 100644 --- a/lib/sqlalchemy/ext/asyncio/session.py +++ b/lib/sqlalchemy/ext/asyncio/session.py @@ -304,7 +304,33 @@ class AsyncSession: return await greenlet_spawn(self.sync_session.commit) async def close(self): - """Close this :class:`_asyncio.AsyncSession`.""" + """Close out the transactional resources and ORM objects used by this + :class:`_asyncio.AsyncSession`. + + This expunges all ORM objects associated with this + :class:`_asyncio.AsyncSession`, ends any transaction in progress and + :term:`releases` any :class:`_asyncio.AsyncConnection` objects which + this :class:`_asyncio.AsyncSession` itself has checked out from + associated :class:`_asyncio.AsyncEngine` objects. The operation then + leaves the :class:`_asyncio.AsyncSession` in a state which it may be + used again. + + .. tip:: + + The :meth:`_asyncio.AsyncSession.close` method **does not prevent + the Session from being used again**. The + :class:`_asyncio.AsyncSession` itself does not actually have a + distinct "closed" state; it merely means the + :class:`_asyncio.AsyncSession` will release all database + connections and ORM objects. + + + .. seealso:: + + :ref:`session_closing` - detail on the semantics of + :meth:`_asyncio.AsyncSession.close` + + """ return await greenlet_spawn(self.sync_session.close) @classmethod |