[GRASS-SVN] r56516 - grass/trunk/lib/python/temporal

svn_grass at osgeo.org svn_grass at osgeo.org
Fri May 31 00:57:45 PDT 2013


Author: huhabla
Date: 2013-05-31 00:57:44 -0700 (Fri, 31 May 2013)
New Revision: 56516

Modified:
   grass/trunk/lib/python/temporal/abstract_space_time_dataset.py
   grass/trunk/lib/python/temporal/core.py
   grass/trunk/lib/python/temporal/mapcalc.py
Log:
Implemented the rollback function of postgresql, fixed t.*.mapcalc bug


Modified: grass/trunk/lib/python/temporal/abstract_space_time_dataset.py
===================================================================
--- grass/trunk/lib/python/temporal/abstract_space_time_dataset.py	2013-05-30 18:28:35 UTC (rev 56515)
+++ grass/trunk/lib/python/temporal/abstract_space_time_dataset.py	2013-05-31 07:57:44 UTC (rev 56516)
@@ -1017,6 +1017,7 @@
                 where, order, dbif)
         except:
             try:
+                dbif.rollback()
                 rows = self.get_registered_maps(
                     "id,start_time,end_time", 
                     where, order, dbif)

Modified: grass/trunk/lib/python/temporal/core.py
===================================================================
--- grass/trunk/lib/python/temporal/core.py	2013-05-30 18:28:35 UTC (rev 56515)
+++ grass/trunk/lib/python/temporal/core.py	2013-05-31 07:57:44 UTC (rev 56516)
@@ -370,6 +370,17 @@
             self.dbmi = sqlite3
         else:
             self.dbmi = psycopg2
+            
+    def rollback(self):
+        """
+            Roll back the last transaction. This must be called 
+            in case a new query should be performed after a db error.
+            
+            This is only relevant for postgresql database.
+        """
+        if self.dbmi.__name__ == "psycopg2":
+            if self.connected:
+                self.connection.rollback()
 
     def connect(self):
         """!Connect to the DBMI to execute SQL statements

Modified: grass/trunk/lib/python/temporal/mapcalc.py
===================================================================
--- grass/trunk/lib/python/temporal/mapcalc.py	2013-05-30 18:28:35 UTC (rev 56515)
+++ grass/trunk/lib/python/temporal/mapcalc.py	2013-05-31 07:57:44 UTC (rev 56516)
@@ -300,11 +300,11 @@
             proc_list[proc_count].start()
             proc_count += 1
 
-            if proc_count == nprocs or proc_count == num:
+            if proc_count == nprocs or proc_count == num or count == num:
                 proc_count = 0
                 exitcodes = 0
-                proc.join()
                 for proc in proc_list:
+                    proc.join()
                     exitcodes += proc.exitcode
 
                 if exitcodes != 0:



More information about the grass-commit mailing list