diff options
author | Stefan Hacker <dd0t@users.sourceforge.net> | 2010-05-30 18:04:45 +0400 |
---|---|---|
committer | Stefan Hacker <dd0t@users.sourceforge.net> | 2010-05-30 18:04:45 +0400 |
commit | 794af445c9eef3fc0ef89970afb7ff302d2aeb29 (patch) | |
tree | 60c157888ae7eedb38a5cff1bff8e8b02aaa3051 | |
parent | c2dad1ba8d5ff3dea82df2f807bc160c5811b724 (diff) |
Make authenticator retry every database operation once. This should solve problems with timeouts.
-rw-r--r-- | Authenticators/phpBB3/phpBB3auth.py | 17 |
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) |