Skip to content
Snippets Groups Projects
Commit 31005d24 authored by Andreas Valder's avatar Andreas Valder
Browse files

fixed restarting transactions... again

parent a166ca9c
No related branches found
No related tags found
No related merge requests found
......@@ -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
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()
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()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment