add lock_for_insert routine but comment out for now (hangs)
This commit is contained in:
parent
5d5a6ed39d
commit
12e1da0a5e
|
@ -505,6 +505,14 @@ class Database:
|
|||
# Start of Hand Writing routines. Idea is to provide a mixture of routines to store Hand data
|
||||
# however the calling prog requires. Main aims:
|
||||
# - existing static routines from fpdb_simple just modified
|
||||
|
||||
def lock_for_insert(self):
|
||||
"""Lock tables in MySQL to try to speed inserts up"""
|
||||
try:
|
||||
self.get_cursor().execute(self.sql.query['lockForInsert'])
|
||||
except:
|
||||
print "Error during fdb.lock_for_insert:", str(sys.exc_value)
|
||||
#end def lock_for_insert
|
||||
|
||||
|
||||
def storeHands(self, backend, site_hand_no, gametype_id
|
||||
|
|
|
@ -1562,6 +1562,13 @@ class Sql:
|
|||
else: # assume postgres
|
||||
self.query['analyze'] = "vacuum analyze"
|
||||
|
||||
if db_server == 'mysql':
|
||||
self.query['lockForInsert'] = """
|
||||
lock tables hands write, handsplayers write, handsactions write, players write, hudcache write
|
||||
"""
|
||||
else: # assume postgres
|
||||
self.query['lockForInsert'] = ""
|
||||
|
||||
if __name__== "__main__":
|
||||
# just print the default queries and exit
|
||||
s = Sql(game = 'razz', type = 'ptracks')
|
||||
|
|
|
@ -84,7 +84,7 @@ class Importer:
|
|||
self.fdb.db.rollback() # make sure all locks are released
|
||||
|
||||
self.NEWIMPORT = False
|
||||
self.allow_hudcache_rebuild = True;
|
||||
self.allow_hudcache_rebuild = False;
|
||||
|
||||
#Set functions
|
||||
def setCallHud(self, value):
|
||||
|
@ -199,7 +199,7 @@ class Importer:
|
|||
self.fdb.afterBulkImport()
|
||||
else:
|
||||
print "No need to rebuild indexes."
|
||||
if self.settings['dropHudCache'] == 'drop':
|
||||
if self.allow_hudcache_rebuild and self.settings['dropHudCache'] == 'drop':
|
||||
self.database.rebuild_hudcache()
|
||||
else:
|
||||
print "No need to rebuild hudcache."
|
||||
|
@ -323,24 +323,6 @@ class Importer:
|
|||
|
||||
filter_name = filter.replace("ToFpdb", "")
|
||||
|
||||
# Example code for using threads & queues: (maybe for obj and import_fpdb_file??)
|
||||
#def worker():
|
||||
# while True:
|
||||
# item = q.get()
|
||||
# do_work(item)
|
||||
# q.task_done()
|
||||
#
|
||||
#q = Queue()
|
||||
#for i in range(num_worker_threads):
|
||||
# t = Thread(target=worker)
|
||||
# t.setDaemon(True)
|
||||
# t.start()
|
||||
#
|
||||
#for item in source():
|
||||
# q.put(item)
|
||||
#
|
||||
#q.join() # block until all tasks are done
|
||||
|
||||
mod = __import__(filter)
|
||||
obj = getattr(mod, filter_name, None)
|
||||
if callable(obj):
|
||||
|
@ -397,6 +379,9 @@ class Importer:
|
|||
self.pos_in_file[file] = inputFile.tell()
|
||||
inputFile.close()
|
||||
|
||||
# fix fdb and database cursors before using this:
|
||||
#self.database.lock_for_insert() # ok when using one thread
|
||||
|
||||
try: # sometimes we seem to be getting an empty self.lines, in which case, we just want to return.
|
||||
firstline = self.lines[0]
|
||||
except:
|
||||
|
|
Loading…
Reference in New Issue
Block a user