MCPcopy Create free account
hub / github.com/sqlalchemy/sqlalchemy / reset

Method reset

lib/sqlalchemy/orm/session.py:2531–2554  ·  view source on GitHub ↗

Close out the transactional resources and ORM objects used by this :class:`_orm.Session`, resetting the session to its initial state. This method provides for same "reset-only" behavior that the :meth:`_orm.Session.close` method has provided historically, where the s

(self)

Source from the content-addressed store, hash-verified

2529 self._close_impl(invalidate=False)
2530
2531 def reset(self) -> None:
2532 """Close out the transactional resources and ORM objects used by this
2533 :class:`_orm.Session`, resetting the session to its initial state.
2534
2535 This method provides for same "reset-only" behavior that the
2536 :meth:`_orm.Session.close` method has provided historically, where the
2537 state of the :class:`_orm.Session` is reset as though the object were
2538 brand new, and ready to be used again.
2539 This method may then be useful for :class:`_orm.Session` objects
2540 which set :paramref:`_orm.Session.close_resets_only` to ``False``,
2541 so that "reset only" behavior is still available.
2542
2543 .. versionadded:: 2.0.22
2544
2545 .. seealso::
2546
2547 :ref:`session_closing` - detail on the semantics of
2548 :meth:`_orm.Session.close` and :meth:`_orm.Session.reset`.
2549
2550 :meth:`_orm.Session.close` - a similar method will additionally
2551 prevent reuse of the Session when the parameter
2552 :paramref:`_orm.Session.close_resets_only` is set to ``False``.
2553 """
2554 self._close_impl(invalidate=False, is_reset=True)
2555
2556 def invalidate(self) -> None:
2557 """Close this Session, using connection invalidation.

Callers 1

addMethod · 0.45

Calls 1

_close_implMethod · 0.95

Tested by

no test coverage detected