Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mumble-voip/mumble-scripts.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Hacker <dd0t@users.sourceforge.net>2010-05-30 18:04:45 +0400
committerStefan Hacker <dd0t@users.sourceforge.net>2010-05-30 18:04:45 +0400
commit794af445c9eef3fc0ef89970afb7ff302d2aeb29 (patch)
tree60c157888ae7eedb38a5cff1bff8e8b02aaa3051
parentc2dad1ba8d5ff3dea82df2f807bc160c5811b724 (diff)
Make authenticator retry every database operation once. This should solve problems with timeouts.
-rw-r--r--Authenticators/phpBB3/phpBB3auth.py17
1 files changed, 16 insertions, 1 deletions
diff --git a/Authenticators/phpBB3/phpBB3auth.py b/Authenticators/phpBB3/phpBB3auth.py
index 898f2b6..965a6ed 100644
--- a/Authenticators/phpBB3/phpBB3auth.py
+++ b/Authenticators/phpBB3/phpBB3auth.py
@@ -168,6 +168,14 @@ class threadDB(object):
cursor = classmethod(cursor)
def execute(cls, *args, **kwargs):
+ if "threadDB__retry_execution__" in kwargs:
+ # Have a magic keyword so we can call ourselves while preventing
+ # an infinite loop
+ del kwargs["threadDB__retry_execution__"]
+ retry = False
+ else:
+ retry = True
+
c = cls.cursor()
try:
c.execute(*args, **kwargs)
@@ -175,7 +183,14 @@ class threadDB(object):
error('Database operational error %d: %s', e.args[0], e.args[1])
c.close()
cls.invalidate_connection()
- raise threadDbException()
+ if retry:
+ # Make sure we only retry once
+ info('Retrying database operation')
+ kwargs["threadDB__retry_execution__"] = True
+ c = cls.execute(*args, **kwargs)
+ else:
+ error('Database operation failed ultimately')
+ raise threadDbException()
return c
execute = classmethod(execute)