[SQL-CVS] r556 - trunk/SQLObject/sqlobject
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
|
From: <sub...@co...> - 2005-01-28 20:48:30
|
Author: ianb
Date: 2005-01-28 20:48:00 +0000 (Fri, 28 Jan 2005)
New Revision: 556
Modified:
trunk/SQLObject/sqlobject/dbconnection.py
Log:
* Be a little more robust about closing a DBConnection instance,
and closing all its direct connections
* When there's no pooling (typically in a transaction) make sure
you explicitly close connections that are released.
Modified: trunk/SQLObject/sqlobject/dbconnection.py
===================================================================
--- trunk/SQLObject/sqlobject/dbconnection.py 2005-01-26 06:07:52 UTC (rev 555)
+++ trunk/SQLObject/sqlobject/dbconnection.py 2005-01-28 20:48:00 UTC (rev 556)
@@ -176,6 +176,8 @@
# the __del__ in Iteration (unfortunately, not sure why
# it happens)
self._pool.append(conn)
+ else:
+ conn.close()
def printDebug(self, conn, s, name, type='query'):
if type == 'query':
@@ -478,12 +480,21 @@
self.close()
def close(self):
- if self._pool:
- for conn in self._pool:
+ if not self._pool:
+ return
+ self._poolLock.acquire()
+ try:
+ conns = self._pool[:]
+ self._pool[:] = []
+ for conn in conns:
try:
conn.close()
except self.module.Error:
pass
+ del conn
+ del conns
+ finally:
+ self._poolLock.release()
class Iteration(object):
|