[Pywikipedia-l] SVN: [5725] trunk/pywikipedia/wikipedia.py
russblau at svn.wikimedia.org
russblau at svn.wikimedia.org
Thu Jul 17 13:39:55 UTC 2008
Revision: 5725
Author: russblau
Date: 2008-07-17 13:39:55 +0000 (Thu, 17 Jul 2008)
Log Message:
-----------
Better catching of HTTP 503 errors.
Modified Paths:
--------------
trunk/pywikipedia/wikipedia.py
Modified: trunk/pywikipedia/wikipedia.py
===================================================================
--- trunk/pywikipedia/wikipedia.py 2008-07-17 12:01:31 UTC (rev 5724)
+++ trunk/pywikipedia/wikipedia.py 2008-07-17 13:39:55 UTC (rev 5725)
@@ -1354,6 +1354,18 @@
return None
try:
response, data = self.site().postForm(address, predata, sysop)
+ if response.status == 503:
+ if 'x-database-lag' in response.msg.keys():
+ # server lag; Mediawiki recommends waiting 5 seconds
+ # and retrying
+ if verbose:
+ output(data, newline=False)
+ output(u"Pausing 5 seconds due to database server lag.")
+ dblagged = True
+ time.sleep(5)
+ continue
+ # Squid error 503
+ raise ServerError(response)
except httplib.BadStatusLine, line:
raise PageNotSaved('Bad status line: %s' % line.line)
except ServerError:
@@ -1366,16 +1378,6 @@
if retry_delay > 30:
retry_delay = 30
continue
- if response.status == 503 \
- and 'x-database-lag' in response.msg.keys():
- # server lag; Mediawiki recommends waiting 5 seconds and
- # retrying
- if verbose:
- output(data, newline=False)
- output(u"Pausing 5 seconds due to database server lag.")
- dblagged = True
- time.sleep(5)
- continue
# If it has gotten this far then we should reset dblagged
dblagged = False
# Check blocks
More information about the Pywikipedia-l
mailing list