always release locks when db work finished

This commit is contained in:
sqlcoder 2009-04-26 21:47:28 +01:00 committed by Worros
parent d9d8043888
commit 326f29b5b6

View File

@ -74,6 +74,7 @@ class Importer:
self.fdb = fpdb_db.fpdb_db() # sets self.fdb.db self.fdb.cursor and self.fdb.sql self.fdb = fpdb_db.fpdb_db() # sets self.fdb.db self.fdb.cursor and self.fdb.sql
self.fdb.do_connect(self.config) self.fdb.do_connect(self.config)
self.fdb.db.rollback()
#Set functions #Set functions
def setCallHud(self, value): def setCallHud(self, value):
@ -348,6 +349,7 @@ class Importer:
self.caller.pipe_to_hud.stdin.write("%s" % (handsId) + os.linesep) self.caller.pipe_to_hud.stdin.write("%s" % (handsId) + os.linesep)
except fpdb_simple.DuplicateError: except fpdb_simple.DuplicateError:
duplicates += 1 duplicates += 1
self.fdb.db.rollback()
except (ValueError), fe: except (ValueError), fe:
errors += 1 errors += 1
self.printEmailErrorMessage(errors, file, hand) self.printEmailErrorMessage(errors, file, hand)
@ -355,6 +357,8 @@ class Importer:
if (self.settings['failOnError']): if (self.settings['failOnError']):
self.fdb.db.commit() #dont remove this, in case hand processing was cancelled. self.fdb.db.commit() #dont remove this, in case hand processing was cancelled.
raise raise
else:
self.fdb.db.rollback()
except (fpdb_simple.FpdbError), fe: except (fpdb_simple.FpdbError), fe:
errors += 1 errors += 1
self.printEmailErrorMessage(errors, file, hand) self.printEmailErrorMessage(errors, file, hand)