From 14dc35ef815da8da40e0de7542a3cd2549280f3d Mon Sep 17 00:00:00 2001 From: Mika Bostrom Date: Mon, 6 Jul 2009 00:15:37 +0300 Subject: [PATCH] Fix initial run with postgres Simplify error check, so that regardless of how the table name is mangled, we now catch just the meaningful part. When trying to obtain the lock, make sure that there is no transaction block open (which tends to happen on error-paths); flush the database connection before requesting exclusive lock. --- pyfpdb/fpdb_db.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pyfpdb/fpdb_db.py b/pyfpdb/fpdb_db.py index e3bf3d2a..2ec96580 100644 --- a/pyfpdb/fpdb_db.py +++ b/pyfpdb/fpdb_db.py @@ -589,11 +589,12 @@ class fpdb_db: return(1) elif self.backend == self.PGSQL: try: + self.db.commit() self.cursor.execute( "lock table Players in exclusive mode nowait" ) #print "... after lock table, status =", self.cursor.statusmessage except: # relation "players" does not exist - if str(sys.exc_value).find('relation "Players" does not exist') >= 0: + if str(sys.exc_value).find('does not exist') >= 0: return(2) print "Error! failed to obtain global lock. Close all programs accessing " \ + "database (including fpdb) and try again (%s)." \