From ae9e931d85bd0494b61db2c7b204a43a0c61467c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Brunner?= Date: Tue, 3 Oct 2023 15:55:11 +0200 Subject: [PATCH] Call later to fix SQLAlchemy error --- c2cwsgiutils/request_tracking/_sql.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/c2cwsgiutils/request_tracking/_sql.py b/c2cwsgiutils/request_tracking/_sql.py index e06d78222..f7507088e 100644 --- a/c2cwsgiutils/request_tracking/_sql.py +++ b/c2cwsgiutils/request_tracking/_sql.py @@ -15,4 +15,5 @@ def _add_session_id(session: Session, _transaction: Any, _connection: Any) -> No def init() -> None: """Initialize the SQL alchemy session selector.""" - sqlalchemy.event.listen(Session, "after_begin", _add_session_id) + + sqlalchemy.event.listen(Session, "after_transaction_create", _add_session_id)