2022-02-24 09:05:10 |
Rodolfo Alonso |
description |
The ``Session.autocommit`` parameter is deprecated and will be removed in SQLAlchemy version 2.0. The Session now features ``autobegin`` behavior such that the Session.begin() method may be called if a transaction has not yet been started yet. See the section session_explicit_begin for background.
In Neutron/neutron-lib, the property ``Session.is_active`` [1] is used to determine if a session has an active transaction. With "autocommit=False", the transaction is never closed once created. That means the property will return "True" even when the transaction has flushed all pending commands.
In order to mimic the previous behaviour, we need to find an alternative method to decide if the session has any pending command to be flushed.
[1]https://github.com/sqlalchemy/sqlalchemy/blob/878c37614efd311794aa50467dbb9e3fe972fdff/lib/sqlalchemy/orm/session.py#L3809-L3837 |
The ``Session.autocommit`` parameter is deprecated and will be removed in SQLAlchemy version 2.0. The Session now features ``autobegin`` behavior such that the Session.begin() method may be called if a transaction has not yet been started yet. See the section session_explicit_begin for background.
In Neutron/neutron-lib, the property ``Session.is_active`` [1] is used to determine if a session has an active transaction. With "autocommit=False", the transaction is never closed once created. That means the property will return "True" even when the transaction has flushed all pending commands.
In order to mimic the previous behaviour, we need to find an alternative method to decide if the session has any pending command to be flushed.
Related topic: https://review.opendev.org/q/topic:sqlalchemy-20
[1]https://github.com/sqlalchemy/sqlalchemy/blob/878c37614efd311794aa50467dbb9e3fe972fdff/lib/sqlalchemy/orm/session.py#L3809-L3837 |
|