reset isolation level fails on invalided connection

Issue #3302 resolved
Mike Bayer repo owner created an issue
>>> from sqlalchemy import create_engine
>>> e = create_engine("sqlite://")  
>>> c1 = e.connect()
>>> c2 = c1.execution_options(isolation_level='SERIALIZABLE')
>>> c2.invalidate()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/classic/dev/sqlalchemy/lib/sqlalchemy/engine/base.py", line 482, in invalidate
    self._root.__connection.invalidate(exception)
  File "/Users/classic/dev/sqlalchemy/lib/sqlalchemy/pool.py", line 759, in invalidate
    self._checkin()
  File "/Users/classic/dev/sqlalchemy/lib/sqlalchemy/pool.py", line 682, in _checkin
    self._pool, None, self._echo, fairy=self)
  File "/Users/classic/dev/sqlalchemy/lib/sqlalchemy/pool.py", line 580, in _finalize_fairy
    connection_record.checkin()
  File "/Users/classic/dev/sqlalchemy/lib/sqlalchemy/pool.py", line 466, in checkin
    finalizer(connection)
  File "/Users/classic/dev/sqlalchemy/lib/sqlalchemy/engine/default.py", line 454, in reset_isolation_level
    self.set_isolation_level(dbapi_conn, self.default_isolation_level)
  File "/Users/classic/dev/sqlalchemy/lib/sqlalchemy/dialects/sqlite/base.py", line 868, in set_isolation_level
    cursor = connection.cursor()
AttributeError: 'NoneType' object has no attribute 'cursor'
>>> 

Comments (2)

  1. Mike Bayer reporter
    • Fixed bug in :class:.Connection and pool where the :meth:.Connection.invalidate method, or an invalidation due to a database disconnect, would fail if the isolation_level parameter had been used with :meth:.Connection.execution_options; the "finalizer" that resets the isolation level would be called on the no longer opened connection. fixes #3302

    → <<cset 068f9a1531c8>>

  2. Mike Bayer reporter
    • Fixed bug in :class:.Connection and pool where the :meth:.Connection.invalidate method, or an invalidation due to a database disconnect, would fail if the isolation_level parameter had been used with :meth:.Connection.execution_options; the "finalizer" that resets the isolation level would be called on the no longer opened connection. fixes #3302

    (cherry picked from commit 068f9a1531c8114360d5fcd964c27fe6a21f4679)

    → <<cset 7c196d16fed5>>

  3. Log in to comment