Revision: 5796
Author: nicdumz
Date: 2008-08-14 03:11:37 +0000 (Thu, 14 Aug 2008)
Log Message:
-----------
"<siebrand> someone please add a max_retries soon. CommonsDelinker gets fucking
stuck on all kinds of silly server errors all the time.
<siebrand> Got a server error when putting [[wikipedia:ja:????]]; will retry in 30
minutes.
<siebrand> And that somehow never recovers."
Adding config.maxretries = 5, dying in _putPage with wikipedia.ServerError after
config.maxretries retries
Modified Paths:
--------------
trunk/pywikipedia/config.py
trunk/pywikipedia/wikipedia.py
Modified: trunk/pywikipedia/config.py
===================================================================
--- trunk/pywikipedia/config.py 2008-08-11 12:48:14 UTC (rev 5795)
+++ trunk/pywikipedia/config.py 2008-08-14 03:11:37 UTC (rev 5796)
@@ -263,6 +263,9 @@
# what you are doing and have a good reason for it!
maxlag = 5
+# Number of retries before giving up when putting a page
+maxretries = 5
+
# Maximum of pages which can be retrieved by special pages. Increase this if
# you heavily use redirect.py with action "double", and especially if
you're
# running solve_disambiguation.py with the -primary argument.
Modified: trunk/pywikipedia/wikipedia.py
===================================================================
--- trunk/pywikipedia/wikipedia.py 2008-08-11 12:48:14 UTC (rev 5795)
+++ trunk/pywikipedia/wikipedia.py 2008-08-14 03:11:37 UTC (rev 5796)
@@ -1333,6 +1333,7 @@
predata['masteredit'] = '1'
retry_delay = 1
+ retry_attempt = 1
dblagged = False
while True:
# Check whether we are not too quickly after the previous
@@ -1373,6 +1374,9 @@
raise PageNotSaved('Bad status line: %s' % line.line)
except ServerError:
output(u''.join(traceback.format_exception(*sys.exc_info())))
+ retry_attempt += 1
+ if retry_attempt > config.maxretries:
+ raise
output(
u'Got a server error when putting %s; will retry in %i minute%s.'
% (self.aslink(), retry_delay, retry_delay != 1 and "s"
or ""))
Show replies by date