Commit 31005d24 authored by Andreas Valder's avatar Andreas Valder

fixed restarting transactions... again

parent a166ca9c
......@@ -67,15 +67,7 @@ elif config['DB_ENGINE'] == 'mysql':
else:
db = mysql.connector.connect(user=config['MYSQL_USER'], password=config['MYSQL_PASSWD'], unix_socket=config.get('MYSQL_UNIX', None))
cur = db.cursor()
tries = 0
while (tries < 10):
try:
cur.execute(operation)
except mysql.connector.errors.InternalError as e:
if e.msg == 'Deadlock found when trying to get lock; try restarting transaction':
tries += 1
else:
raise
cur.execute(operation)
rows = []
try:
rows = cur.fetchall()
......@@ -95,7 +87,17 @@ elif config['DB_ENGINE'] == 'mysql':
def query(operation, *params, delim="sep", nlfix=True):
operation, params = fix_query(operation, params)
cur = get_dbcursor()
cur.execute(operation, params)
tries = 0
while (tries < 10):
try:
cur.execute(operation, params)
except mysql.connector.errors.InternalError as e:
if e.msg == 'Deadlock found when trying to get lock; try restarting transaction':
tries += 1
continue
else:
raise
break
rows = []
try:
rows = cur.fetchall()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment