[Sqlalchemy-tickets] Issue #3780: connectionless execution causes TLConnection to stay open incorre
Brought to you by:
zzzeek
From: jbeluch <iss...@bi...> - 2016-08-25 14:32:16
|
New issue 3780: connectionless execution causes TLConnection to stay open incorreclty in certain scenarios https://bitbucket.org/zzzeek/sqlalchemy/issues/3780/connectionless-execution-causes jbeluch: Somewhat related to https://bitbucket.org/zzzeek/sqlalchemy/issues/3779/threadlocal-engine-sometimes-doesnt. All calls to .contextual_connect() return the same TLConnection object, however sometimes the caller wants a Connection with the should_close_with_result attr set to True on the connection (connectionless execution via engine.execute). So, if the TLConnection is initially created with close_with_result=False, then calls to engine.execute() will increment the __open_count counter while never calling .close() to decrement it. Failing test: ~~~ def test_tlbind_close_conn(self): e = create_engine(testing.db.url, strategy='threadlocal') conn = e.contextual_connect() e.execute('select 1').fetchall() conn.close() assert conn.closed ~~~ |