What's the deal with the connection timeout behaviour?
I imported an SQLObject I created called Users, selected a couple items from
it, then went away for a while. When I came back and selected another item
from it, it threw an exception saying that the connection had timed out. It
didn't try to reconnect, as you'd expect, but just died.
Then I did another query right afterwards, and it reconnected to the
database and worked fine! This isn't very nice. It should really throw an
exception if it CAN'T reconnect, not if it HAS to reconnect.
Here's an example:
[ ... leave for long time and come back ... ]
>>> u = Users(1)
File "<console>", line 1, in ?
File "C:\PYTHON23\lib\site-packages\SQLObject\SQLObject.py", line 407,
in __new__
val._init(id, connection, selectResults)
File "C:\PYTHON23\lib\site-packages\SQLObject\SQLObject.py", line 667,
in _init
selectResults = self._connection._SO_selectOne(self, dbNames)
File "c:\python23\Lib\site-packages\SQLObject\DBConnection.py", line
306, in _SO_selectOne
return self.queryOne("SELECT %s FROM %s WHERE %s = %s" %
File "c:\python23\Lib\site-packages\SQLObject\DBConnection.py", line
149, in queryOne
return self._runWithConnection(self._queryOne, s)
File "c:\python23\Lib\site-packages\SQLObject\DBConnection.py", line
72, in _runWithConnection
val = meth(conn, *args)
File "c:\python23\Lib\site-packages\SQLObject\DBConnection.py", line
142, in _queryOne
c.execute(s)
File "C:\PYTHON23\Lib\site-packages\MySQLdb\cursors.py", line 95, in
execute
return self._execute(query, args)
File "C:\PYTHON23\Lib\site-packages\MySQLdb\cursors.py", line 114, in
_execute
self.errorhandler(self, exc, value)
File "C:\PYTHON23\Lib\site-packages\MySQLdb\connections.py", line 33,
in defaulterrorhandler
raise errorclass, errorvalue
''' _mysql_exceptions.OperationalError : (2013, 'Lost connection to MySQL
server during query') '''
>>> Users(1)
<Users 1 username='bob' role='csr' fullname='Bob Linklater'
password='48181acd22b3edaebc8a447868a7df7ce629920a'>
>>>
= Chris Gahan =============
(ch...@il...)
|