From 570f1d0cf66b55d2ae6b5d0d6901b8685ebbe477 Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Thu, 25 Mar 2021 20:30:36 +0100 Subject: [PATCH] Passing expire_on_commit=False on sessionmaker() [see #181] Accessing db objects outside of their session seems to fail on SQLAlchemy >= 1.4 with a `Instance `Instance is not bound to a Session` error. Setting expire_on_commit=False on the session seems to somehow fix the issue (see https://stackoverflow.com/questions/3039567/sqlalchemy-detachedinstanceerror-with-regular-attribute-not-a-relation) --- platypush/user/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platypush/user/__init__.py b/platypush/user/__init__.py index 0d304f9f2e..c4950ee390 100644 --- a/platypush/user/__init__.py +++ b/platypush/user/__init__.py @@ -234,7 +234,7 @@ class UserManager: def _get_db_session(self): Base.metadata.create_all(self._engine) - session = scoped_session(sessionmaker()) + session = scoped_session(sessionmaker(expire_on_commit=False)) session.configure(bind=self._engine) return session()