NotImplementedError raised with NullPool when MySQL connection times out

Issue #1094 resolved
Former user created an issue

I've observed this on multiple Windows XP systems; I don't know if it affects other platforms. The systems are running Python 2.5.2 and recent versions of MySQL 5.

This test requires letting the MySQL connection timeout. For this test I configured the MySQL server with a short timeout (ie, 60 seconds), but I've observed this problem with the default (8 hour) timeout as well.

import sqlalchemy import sqlalchemy.orm eng = sqlalchemy.create_engine('mysql://root:rootpw@localhost/testdb', poolclass = sqlalchemy.pool.NullPool) Session = sqlalchemy.orm.sessionmaker() Session.configure(bind = eng) s = Session() s.execute("SELECT 1") <sqlalchemy.engine.base.ResultProxy object at 0x0148B5B0>

Now wait for the MySQL connection to time out, then in the same Python/IDLE instance:

s = Session() s.execute("SELECT 1")

Traceback (most recent call last): File "<pyshell#11>", line 1, in <module> s.execute("SELECT 1") File "C:\Python25\Lib\site-packages\sqlalchemy\orm\session.py", line 625, in execute return self.__connection(engine, close_with_result=True).execute(clause, params or {}) File "C:\Python25\Lib\site-packages\sqlalchemy\engine\base.py", line 844, in execute return Connection.executorsc(self, object, multiparams, params) File "C:\Python25\Lib\site-packages\sqlalchemy\engine\base.py", line 854, in _execute_text self.__execute_raw(context) File "C:\Python25\Lib\site-packages\sqlalchemy\engine\base.py", line 916, in __execute_raw self._cursor_execute(context.cursor, context.statement, context.parameters0, context=context) File "C:\Python25\Lib\site-packages\sqlalchemy\engine\base.py", line 960, in _cursor_execute self._handle_dbapi_exception(e, statement, parameters, cursor) File "C:\Python25\Lib\site-packages\sqlalchemy\engine\base.py", line 935, in _handle_dbapi_exception self.engine.dispose() File "C:\Python25\Lib\site-packages\sqlalchemy\engine\base.py", line 1133, in dispose self.pool.dispose() File "C:\Python25\Lib\site-packages\sqlalchemy\pool.py", line 161, in dispose raise NotImplementedError() NotImplementedError

This can't be reproduced with raw connections (from eng.connect()); it requires using Session objects.

This is in sqlalchemy 0.4.6, though I've seen it in earlier versions.

Comments (6)

  1. Former user Account Deleted

    The formatting for the Python code seems to have been trashed. Here it is again:

    import sqlalchemy import sqlalchemy.orm eng = sqlalchemy.create_engine('mysql://root:rootpw@localhost/testdb', poolclass = sqlalchemy.pool.NullPool) Session = sqlalchemy.orm.sessionmaker() Session.configure(bind = eng) s = Session() s.execute("SELECT 1")

    And then after the timeout:

    s = Session() s.execute("SELECT 1")

  2. Former user Account Deleted

    Trying yet again...

    import sqlalchemy[BR] import sqlalchemy.orm[BR] eng = sqlalchemy.create_engine('mysql://root:rootpw@localhost/testdb', poolclass = sqlalchemy.pool.NullPool)[BR] Session = sqlalchemy.orm.sessionmaker()[BR] Session.configure(bind = eng)[BR] s = Session()[BR] s.execute("SELECT 1")

    And then after the timeout:

    s = Session()[BR] s.execute("SELECT 1")

  3. Mike Bayer repo owner

    im sure it can be reproduced with straight Connections. We have a test suite test/engine/reconnect.py which needs to be generalized to other pool classes besides QueuePool.

  4. Log in to comment