[Sqlalchemy-tickets] Issue #3779: threadlocal engine sometimes doesn't properly close the connectio
Brought to you by:
zzzeek
From: jbeluch <iss...@bi...> - 2016-08-25 14:28:27
|
New issue 3779: threadlocal engine sometimes doesn't properly close the connection https://bitbucket.org/zzzeek/sqlalchemy/issues/3779/threadlocal-engine-sometimes-doesnt jbeluch: In certain scenarios the __opencount attribute on TLConnection gets incremented but not properly decremented, which means the connection doesn't get closed properly unless you resort to _force_close(). Calling TLEngine.begin() returns the engine object itself which has __enter__ and __exit__ methods. While __enter__ will increment the open count, __exit__ doesn't call conn.close() so the count remains higher than it should. Potential PR here: https://github.com/zzzeek/sqlalchemy/pull/301#issuecomment-242161104 Failing test: ~~~ def test_tlbind_close_trans_conn(self): e = create_engine(testing.db.url, strategy='threadlocal') conn = e.contextual_connect() with e.begin(): pass conn.close() assert conn.closed ~~~ |