section. References #3974
Change-Id: Idb650cbe9825cfae893ee917132b5b9d693f0c6c
# as that of commit proceeds.
session.rollback()
raise
+ finally:
+ # close the Session. This will expunge any remaining
+ # objects as well as reset any existing SessionTransaction
+ # state. Neither of these steps are usually essential.
+ # However, if the commit() or rollback() itself experienced
+ # an unanticipated internal failure (such as due to a mis-behaved
+ # user-defined event handler), .close() will ensure that
+ # invalid state is removed.
+ session.close()
.. _session_begin_nested: