gump-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject svn commit: r990014 - in /gump/trunk/python/gump: actor/mysql/databaser.py util/mysql.py
Date Fri, 27 Aug 2010 04:22:21 GMT
Author: bodewig
Date: Fri Aug 27 04:22:21 2010
New Revision: 990014

URL: http://svn.apache.org/viewvc?rev=990014&view=rev
Log:
get rid of "closing a closed connection" warning

Modified:
    gump/trunk/python/gump/actor/mysql/databaser.py
    gump/trunk/python/gump/util/mysql.py

Modified: gump/trunk/python/gump/actor/mysql/databaser.py
URL: http://svn.apache.org/viewvc/gump/trunk/python/gump/actor/mysql/databaser.py?rev=990014&r1=990013&r2=990014&view=diff
==============================================================================
--- gump/trunk/python/gump/actor/mysql/databaser.py (original)
+++ gump/trunk/python/gump/actor/mysql/databaser.py Fri Aug 27 04:22:21 2010
@@ -67,7 +67,9 @@ class Databaser(gump.core.run.actor.Abst
             helper.insert('gump_module_run', settings)
 
         finally:
-            if conn:
+            if helper:
+                helper.close()
+            elif conn:
                 conn.close()
 
     def processProject(self, project):
@@ -98,7 +100,9 @@ class Databaser(gump.core.run.actor.Abst
             helper.insert('gump_project_run', settings)
 
         finally:
-            if conn:
+            if helper:
+                helper.close()
+            elif conn:
                 conn.close()
 
 

Modified: gump/trunk/python/gump/util/mysql.py
URL: http://svn.apache.org/viewvc/gump/trunk/python/gump/util/mysql.py?rev=990014&r1=990013&r2=990014&view=diff
==============================================================================
--- gump/trunk/python/gump/util/mysql.py (original)
+++ gump/trunk/python/gump/util/mysql.py Fri Aug 27 04:22:21 2010
@@ -109,6 +109,12 @@ class DbHelper:
         self.database = database
 
     def __del__(self):
+        self.close()
+
+    def close(self):
+        """
+        Closes the connection
+        """
         if self.conn:
             self.conn.close()
             self.conn = None
@@ -138,6 +144,9 @@ class DbHelper:
         return statement
 
     def select(self, table_name, column_name, entity_name, columns):
+        if not self.conn:
+            raise RuntimeError('connection is closed')
+
         statement = self.generateSelect(table_name, column_name, entity_name)
         settings = {}
         cursor = None
@@ -204,6 +213,9 @@ class DbHelper:
         Take a dictionary of settings (column names/types) and 
         perform an insert.
         """
+        if not self.conn:
+            raise RuntimeError('connection is closed')
+
         statement = self.generateInsert(table_name, settings)
         affected = 0
         cursor = None
@@ -241,6 +253,9 @@ class DbHelper:
         Take a dictionary of settings (column names/types) and 
         perform an update. Note: The index is a single name.
         """
+        if not self.conn:
+            raise RuntimeError('connection is closed')
+
         statement = self.generateUpdate(table_name, column_name, entity_name,
                                         settings)
         affected = 0
@@ -276,6 +291,9 @@ class DbHelper:
         Perform an SQL DELETE 
         Index is single name
         """
+        if not self.conn:
+            raise RuntimeError('connection is closed')
+
         statement = self.generateDelete(table_name, column_name, entity_name)
         affected = 0
         cursor = None



Mime
View raw message