From: Federico Caselli Date: Wed, 23 Dec 2020 21:18:36 +0000 (+0100) Subject: Improve async session docs. X-Git-Tag: rel_1_4_0b2~78^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=07fa13e7cd51b034bc790c41c149330729e6a540;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git Improve async session docs. Mention that the context manager is only for convenience, that it's equivalent to calling ``close()`` Change-Id: Ic186167cc3d4bbd7a24701dd6169ed0d515c5dc5 --- diff --git a/doc/build/orm/extensions/asyncio.rst b/doc/build/orm/extensions/asyncio.rst index a22529ec5e..09e76f2ee4 100644 --- a/doc/build/orm/extensions/asyncio.rst +++ b/doc/build/orm/extensions/asyncio.rst @@ -143,6 +143,12 @@ avoided in favor of :meth:`_asyncio.AsyncSession.refresh`, and that appropriate loader options should be employed for :func:`_orm.deferred` columns as well as for :func:`_orm.relationship` constructs. +In the example above the :class:`_asyncio.AsyncSession` is instantiated with an +:class:`_asyncio.AsyncEngine` associated with a particular database URL. +It is then used in a Python asynchronous context manager (i.e. ``async with:`` statement) +so that it is automatically closed at the end of the block; this is equivalent +to calling the :meth:`_asyncio.AsyncSession.close` method. + Adapting ORM Lazy loads to asyncio ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/doc/build/orm/session_basics.rst b/doc/build/orm/session_basics.rst index d7fa9c81ab..23a76b4d01 100644 --- a/doc/build/orm/session_basics.rst +++ b/doc/build/orm/session_basics.rst @@ -69,7 +69,7 @@ may look like:: session.add(some_other_object) session.commit() -Above, the :class:`_orm.Session` is instantiated given an :class:`_engine.Engine` +Above, the :class:`_orm.Session` is instantiated with an :class:`_engine.Engine` associated with a particular database URL. It is then used in a Python context manager (i.e. ``with:`` statement) so that it is automatically closed at the end of the block; this is equivalent