Skip to content
Snippets Groups Projects
Verified Commit fc52332e authored by Michal 'vorner' Vaner's avatar Michal 'vorner' Vaner
Browse files

master: Recover broken cursor

Recover from broken DB connection even if it happens in the
__connection.cursor()
parent 19a3e55e
Branches
Tags
No related merge requests found
......@@ -92,9 +92,9 @@ def transaction_raw(reuse=True):
return __CursorContext(__cache.connection)
def transaction(reuse=True):
result = transaction_raw(reuse)
if reuse:
try: # if the cursor works
result = transaction_raw(True)
result._cursor.execute("SELECT 1")
(one,) = result._cursor.fetchone()
return result
......@@ -105,7 +105,8 @@ def transaction(reuse=True):
del __cache.__dict__['connection']
del __cache.__dict__['context']
return transaction_raw(True)
return result
else:
return transaction_raw(False)
__time_update = 0
__time_db = 0
......
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