From cf1efb8d27cf3f1e2a03d25a71fe1af0c2a72e84 Mon Sep 17 00:00:00 2001 From: Ray Date: Wed, 5 Nov 2008 22:44:29 -0500 Subject: [PATCH] transaction isolation code suggested by sql_coder on the forums --- pyfpdb/Database.py | 4 ++++ pyfpdb/HUD_main.py | 3 +-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/pyfpdb/Database.py b/pyfpdb/Database.py index 63de54b2..4039b256 100644 --- a/pyfpdb/Database.py +++ b/pyfpdb/Database.py @@ -59,6 +59,10 @@ class Database: user = c.supported_databases[db_name].db_user, passwd = c.supported_databases[db_name].db_pass, db = c.supported_databases[db_name].db_name) + cur_iso = self.connection.cursor() + cur_iso.execute('SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED') + cur_iso.close() + except: print "Error opening database connection %s. See error log file." % (file) traceback.print_exc(file=sys.stderr) diff --git a/pyfpdb/HUD_main.py b/pyfpdb/HUD_main.py index a157cf46..b1955a6b 100755 --- a/pyfpdb/HUD_main.py +++ b/pyfpdb/HUD_main.py @@ -89,6 +89,7 @@ def update_HUD(new_hand_id, table_name, config, stat_dict): def read_stdin(): # This is the thread function global hud_dict + db_connection = Database.Database(config, db_name, 'temp') while True: # wait for a new hand number on stdin new_hand_id = sys.stdin.readline() new_hand_id = string.rstrip(new_hand_id) @@ -101,10 +102,8 @@ def read_stdin(): # This is the thread function del(hud_dict[h]) # connect to the db and get basic info about the new hand - db_connection = Database.Database(config, db_name, 'temp') (table_name, max, poker_game) = db_connection.get_table_name(new_hand_id) stat_dict = db_connection.get_stats_from_hand(new_hand_id) - db_connection.close_connection() # if a hud for this table exists, just update it if hud_dict.has_key(table_name):