diff options
| author | Christophe Simonis <christophe@tinyerp.com> | 2009-04-28 16:10:07 +0200 |
|---|---|---|
| committer | Christophe Simonis <christophe@tinyerp.com> | 2009-04-28 16:10:07 +0200 |
| commit | 82b04743288ed9586830806b8bf6c5b1233c58ec (patch) | |
| tree | c2fca1940a24a64a8f9e35d0fecb107e6e07eaa1 /bin/sql_db.py | |
| parent | 8e1ab8207cb1863214b4673ac309157b2a7dd2b1 (diff) | |
[FIX] do not relay on _obj to know if the cursor has been closed
lp bug: https://launchpad.net/bugs/330999 fixed
bzr revid: christophe@tinyerp.com-20090428141007-td39oa95wk5h5dt7
Diffstat (limited to 'bin/sql_db.py')
| -rw-r--r-- | bin/sql_db.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/bin/sql_db.py b/bin/sql_db.py index 1e88f1b66c7..f3b8c86b64c 100644 --- a/bin/sql_db.py +++ b/bin/sql_db.py @@ -71,7 +71,7 @@ class Cursor(object): @wraps(f) def wrapper(self, *args, **kwargs): - if not hasattr(self, '_obj'): + if self.__closed: raise psycopg2.ProgrammingError('Unable to use the cursor after having closing it') return f(self, *args, **kwargs) return wrapper @@ -81,6 +81,7 @@ class Cursor(object): self._serialized = serialized self._cnx = pool.getconn() self._obj = self._cnx.cursor(cursor_factory=psycopg1cursor) + self.__closed = False self.autocommit(False) self.dbname = pool.dbname @@ -89,7 +90,7 @@ class Cursor(object): self.__caller = tuple(stack()[2][1:3]) def __del__(self): - if hasattr(self, '_obj'): + if not self.__closed: if tools.config['log_level'] in (netsvc.LOG_DEBUG, netsvc.LOG_DEBUG_RPC): # Oops. 'self' has not been closed explicitly. # The cursor will be deleted by the garbage collector, @@ -166,6 +167,7 @@ class Cursor(object): # collected as fast as they should). The problem is probably due in # part because browse records keep a reference to the cursor. del self._obj + self.__closed = True self._pool.putconn(self._cnx) @check |
