[Sqlalchemy-tickets] Issue #3866: session.refresh(obj) spawns new connection that are held until se
Brought to you by:
zzzeek
From: literg <iss...@bi...> - 2016-12-01 10:43:52
|
New issue 3866: session.refresh(obj) spawns new connection that are held until session is closed https://bitbucket.org/zzzeek/sqlalchemy/issues/3866/sessionrefresh-obj-spawns-new-connection literg: Environment: MySQL 14.14, SQLAlchemy 1.0.11, 1.0.16, 1.1.4 When using session.refresh(obj) inside session, new connection is spawned and are held until the end of session. Code that i used: ``` #!python session = session_maker() try: yield session session.commit() for obj in session: session.refresh(obj) except Exception as e: session.rollback() raise e finally: session.close() ``` ``` #!python with make_session(...) as session: for mapped in [self._mapper.map(obj) for obj in objects]: saved_entities.append(mapped) session.add(mapped) session.flush() ``` Hint: The curious thing is that when i use session.commit() after session.refresh(obj) the connection is reused by next session.refresh(obj) invocation. |