Try to fix two HUD main hangs
The main HUD process can hang due to unhandled exceptions, which occurred in two separate situations: 1. Table window is closed and HUD instance killed before auto-importer knows about it 2. Sometimes the threading can jam These changes attempt to counter the effect of race-conditions. The dictionary key (table name) is properly tested at the beginning of update/create block, *but* there are two short round-trips to database before the key is used. While these occur, the HUD instance can vanish and thus get its key removed from the dictionary. Also, when Tables.Table() is created, it will be populated on-demand, and have child attributes only when such are found from the system. The new table code pulls in data from actual windows. Again, there is a query involved and while it runs, the table may have vanished. This ended up as an error in this call: foo = gtk.gdk.window_foreign_new(table.number) The object 'table' is valid (not None) but it has been populated only after actual table window was killed. Therefore it may not have .number attribute, which raised an AttributeError. Now the presence of table.number attribute is tested before the object can be sent to create_HUD().
This commit is contained in:
parent
5435c164f9
commit
cb9e2cb6e7
|
@ -122,9 +122,9 @@ class HUD_main(object):
|
||||||
m.update_gui(new_hand_id)
|
m.update_gui(new_hand_id)
|
||||||
self.hud_dict[table_name].update(new_hand_id, self.config)
|
self.hud_dict[table_name].update(new_hand_id, self.config)
|
||||||
self.hud_dict[table_name].reposition_windows()
|
self.hud_dict[table_name].reposition_windows()
|
||||||
return False
|
|
||||||
finally:
|
finally:
|
||||||
gtk.gdk.threads_leave()
|
gtk.gdk.threads_leave()
|
||||||
|
return False
|
||||||
|
|
||||||
self.hud_dict[table_name] = Hud.Hud(self, table, max, poker_game, self.config, self.db_connection)
|
self.hud_dict[table_name] = Hud.Hud(self, table, max, poker_game, self.config, self.db_connection)
|
||||||
self.hud_dict[table_name].table_name = table_name
|
self.hud_dict[table_name].table_name = table_name
|
||||||
|
@ -214,7 +214,14 @@ class HUD_main(object):
|
||||||
self.db_connection.init_hud_stat_vars( self.hud_dict[temp_key].hud_params['hud_days']
|
self.db_connection.init_hud_stat_vars( self.hud_dict[temp_key].hud_params['hud_days']
|
||||||
, self.hud_dict[temp_key].hud_params['h_hud_days'])
|
, self.hud_dict[temp_key].hud_params['h_hud_days'])
|
||||||
stat_dict = self.db_connection.get_stats_from_hand(new_hand_id, type, self.hud_dict[temp_key].hud_params, self.hero_ids[site_id])
|
stat_dict = self.db_connection.get_stats_from_hand(new_hand_id, type, self.hud_dict[temp_key].hud_params, self.hero_ids[site_id])
|
||||||
|
try:
|
||||||
self.hud_dict[temp_key].stat_dict = stat_dict
|
self.hud_dict[temp_key].stat_dict = stat_dict
|
||||||
|
except KeyError: # HUD instance has been killed off, key is stale
|
||||||
|
sys.stderr.write('hud_dict[%s] was not found\n' % temp_key)
|
||||||
|
sys.stderr.write('will not send hand\n')
|
||||||
|
# Unlocks table, copied from end of function
|
||||||
|
self.db_connection.connection.rollback()
|
||||||
|
return
|
||||||
cards = self.db_connection.get_cards(new_hand_id)
|
cards = self.db_connection.get_cards(new_hand_id)
|
||||||
comm_cards = self.db_connection.get_common_cards(new_hand_id)
|
comm_cards = self.db_connection.get_common_cards(new_hand_id)
|
||||||
if comm_cards != {}: # stud!
|
if comm_cards != {}: # stud!
|
||||||
|
@ -245,7 +252,12 @@ class HUD_main(object):
|
||||||
else:
|
else:
|
||||||
tablewindow.max = max
|
tablewindow.max = max
|
||||||
tablewindow.site = site_name
|
tablewindow.site = site_name
|
||||||
|
# Test that the table window still exists
|
||||||
|
if hasattr(tablewindow, 'number'):
|
||||||
self.create_HUD(new_hand_id, tablewindow, temp_key, max, poker_game, type, stat_dict, cards)
|
self.create_HUD(new_hand_id, tablewindow, temp_key, max, poker_game, type, stat_dict, cards)
|
||||||
|
else:
|
||||||
|
sys.stderr.write('Table "%s" no longer exists\n', table_name)
|
||||||
|
|
||||||
self.db_connection.connection.rollback()
|
self.db_connection.connection.rollback()
|
||||||
|
|
||||||
if __name__== "__main__":
|
if __name__== "__main__":
|
||||||
|
|
Loading…
Reference in New Issue
Block a user