[Zope-Checkins] CVS: Products/DCOracle2 - db.py:1.13.2.1

Chris Withers cvs-admin at zope.org
Mon Nov 3 10:21:38 EST 2003


Update of /cvs-repository/Products/DCOracle2
In directory cvs.zope.org:/tmp/cvs-serv10511

Modified Files:
      Tag: chrisw_fixconnectionleak_branch
	db.py 
Log Message:
Give DB instances a close method. Call this from __del__. This should make sure that database connections are really closed when we tell them to.


=== Products/DCOracle2/db.py 1.13 => 1.13.2.1 ===
--- Products/DCOracle2/db.py:1.13	Wed May 15 17:14:23 2002
+++ Products/DCOracle2/db.py	Mon Nov  3 10:21:38 2003
@@ -112,10 +112,18 @@
         db=self.db=DCOracle2.connect(connection_string)
         self.cursor=db.cursor()
 
+    def close(self):
+        if hasattr(self,'cursor'):
+            if self.cursor.isOpen():
+                self.cursor.close()
+            del self.cursor
+        if hasattr(self,'db'):
+            if self.db.isOpen():
+                self.db.close()
+            del self.db
+            
     def __del__(self):
-        #print "Deleting DCoracle2 connection"
-        self.cursor = None      # Break reference
-        self.db = None
+        self.close()
         
     def str(self,v, StringType=type('')):
         if v is None: return ''




More information about the Zope-Checkins mailing list