threadlocal engine sometimes doesn't properly close the connection

Issue #3779 new
jbeluch created an issue

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

Comments (2)

  1. Log in to comment