]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
Implement explicit autobegin step for Session
authorMike Bayer <mike_mp@zzzcomputing.com>
Thu, 2 Jan 2020 17:48:23 +0000 (12:48 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Fri, 3 Jan 2020 18:30:53 +0000 (13:30 -0500)
commit0a8b11bb6528c38dc441caadc6eb2d25046fc376
tree90f739e15b296ff8ab54f48a7df9806849c58d83
parent5881fd274015af3de37f2ff0f91ff6a7c61c1540
Implement explicit autobegin step for Session

The :class:`.Session` object no longer initates a
:class:`.SessionTransaction` object immediately upon construction or after
the previous transaction is closed; instead, "autobegin" logic now
initiates the new :class:`.SessionTransaction` on demand when it is next
needed.  Rationale includes to remove reference cycles from a
:class:`.Session` that has been closed out, as well as to remove the
overhead incurred by the creation of :class:`.SessionTransaction` objects
that are often discarded immediately. This change affects the behavior of
the :meth:`.SessionEvents.after_transaction_create` hook in that the event
will be emitted when the :class:`.Session` first requires a
:class:`.SessionTransaction` be present, rather than whenever the
:class:`.Session` were created or the previous :class:`.SessionTransaction`
were closed.   Interactions with the :class:`.Engine` and the database
itself remain unaffected.

Fixes: #5074
Change-Id: I00b656eb5ee03d87104257a214214617aacae16c
doc/build/changelog/migration_14.rst
lib/sqlalchemy/orm/session.py
test/aaa_profiling/test_memusage.py
test/aaa_profiling/test_orm.py
test/orm/test_events.py
test/orm/test_session.py
test/orm/test_transaction.py