Thread: [SQLObject] patch for sqlite timeout specification
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: Dan P. <da...@ag...> - 2006-05-31 12:18:45
Attachments:
sqlobject-sqlite-timeout-fix.patch
|
When I specify a timeout for a sqlite connection that uses the older sqlite db module I get the following warning: /usr/lib/python2.3/site-packages/sqlite/main.py:472: DeprecationWarning: integer argument expected, got float self.db.sqlite_busy_timeout(timeout) This is because the older sqlite module expects the timeout as an integer representing the number of milliseconds, while the newer pysqlite2 wants a float with the number of seconds. The attached patch fixes the issue and also unifies how the timeout is specified for sqlite connections. The timeout parameters in sqlobject will always be in seconds and internally will be sent as the integer number of milliseconds if the sqlite backend is the old one. -- Dan |
From: Oleg B. <ph...@ph...> - 2006-05-31 18:29:32
|
On Wed, May 31, 2006 at 03:18:38PM +0300, Dan Pascu wrote: > The attached patch fixes the issue and also unifies how the timeout is > specified for sqlite connections. The timeout parameters in sqlobject > will always be in seconds and internally will be sent as the integer > number of milliseconds if the sqlite backend is the old one. Thank you. I'll test your patches later. Oleg. -- Oleg Broytmann http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: Oleg B. <ph...@ph...> - 2006-06-14 14:47:55
|
On Wed, May 31, 2006 at 03:18:38PM +0300, Dan Pascu wrote: > - opts['timeout'] = float(popKey(kw, 'timeout')) > + if using_sqlite2: > + opts['timeout'] = float(popKey(kw, 'timeout')) > + else: > + opts['timeout'] = int(float(popKey(kw, 'timeout')) * 1000) Applied in the rev. 1807 to the trunk, 1808 to the 0.7 branch. Thank you! Oleg. -- Oleg Broytmann http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: Dan P. <da...@ag...> - 2006-06-15 11:11:28
|
On Wednesday 14 June 2006 17:47, Oleg Broytmann wrote: > On Wed, May 31, 2006 at 03:18:38PM +0300, Dan Pascu wrote: > > - opts['timeout'] = float(popKey(kw, 'timeout')) > > + if using_sqlite2: > > + opts['timeout'] = float(popKey(kw, 'timeout')) > > + else: > > + opts['timeout'] = int(float(popKey(kw, 'timeout')) * > > 1000) > > Applied in the rev. 1807 to the trunk, 1808 to the 0.7 branch. Thank > you! Thanks for considering it. What about the other 2 patches I sent? The one to break some cyclic references and the other to avoid the call to transaction.rollback() from the transaction __del__() method if a transaction was not successfully instantiated (__init__ failed). -- Dan |
From: Oleg B. <ph...@ma...> - 2006-06-15 12:21:29
|
On Thu, Jun 15, 2006 at 02:11:12PM +0300, Dan Pascu wrote: > What about the other 2 patches I sent? > The one to break some cyclic references I am going to test it, but I think I will apply it after 0.7.1. > and the other to avoid the call to > transaction.rollback() from the transaction __del__() method if a > transaction was not successfully instantiated (__init__ failed). I don't remember if I saw it. Oleg. -- Oleg Broytmann http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: Dan P. <da...@ag...> - 2006-06-15 15:41:58
Attachments:
sqlobject-fix-bogus-rollback-call.patch
|
On Thursday 15 June 2006 15:21, Oleg Broytmann wrote: > On Thu, Jun 15, 2006 at 02:11:12PM +0300, Dan Pascu wrote: > > What about the other 2 patches I sent? > > The one to break some cyclic references > > I am going to test it, but I think I will apply it after 0.7.1. > > > and the other to avoid the call to > > transaction.rollback() from the transaction __del__() method if a > > transaction was not successfully instantiated (__init__ failed). > > I don't remember if I saw it. You did because you said the problem was already fixed in svn, but the fix in svn was only for an AttributeError exception when accessing self._obsolete in __del__(), while the call to rollback still remains. Basically the issue is here: class Transaction(object): def __init__(self, dbConnection): self._obsolete = False self._dbConnection = dbConnection self._connection = dbConnection.getConnection() self._dbConnection._setAutoCommit(self._connection, 0) self.cache = CacheSet(cache=dbConnection.doCache) self._deletedCache = {} ... def __del__(self): if self._obsolete: return self.rollback() Now if it fails in self._connection = dbConnection.getConnection() and raises an exception, it will call __del__() which sees self._obsolete as False and goes on to rollback() which will raise another exception since self._connection doesn't exist. My patch did mark the transaction as obsolete until the connection was actually created, to avoid this (see the attached patch). You can move the second self._obsolete assignment before the cache creation if you think that can be an issue. > > Oleg. -- Dan |
From: Oleg B. <ph...@ph...> - 2006-06-15 16:00:45
|
On Thu, Jun 15, 2006 at 06:41:42PM +0300, Dan Pascu wrote: > You did because you said the problem was already fixed in svn, but the fix > in svn was only for an AttributeError exception when accessing > self._obsolete in __del__(), while the call to rollback still remains. Somehow I've lost and forgot it. Thank you, I'll test it. Oleg. -- Oleg Broytmann http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: Oleg B. <ph...@ph...> - 2006-08-02 14:33:08
|
On Thu, Jun 15, 2006 at 06:41:42PM +0300, Dan Pascu wrote: > --- dbconnection.py.orig 2006-06-15 18:35:14.000000000 +0300 > +++ dbconnection.py 2006-06-15 18:36:03.000000000 +0300 > @@ -784,12 +784,13 @@ > class Transaction(object): > > def __init__(self, dbConnection): > - self._obsolete = False > + self._obsolete = True > self._dbConnection = dbConnection > self._connection = dbConnection.getConnection() > self._dbConnection._setAutoCommit(self._connection, 0) > self.cache = CacheSet(cache=dbConnection.doCache) > self._deletedCache = {} > + self._obsolete = False Applied in the revision 1838 to the trunk, rev.1839 to the 0.7-bugfix branch. Thank you! Oleg. -- Oleg Broytmann http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |