From 20f9231e7c02ca28ce6b75c9499247bbde4b26f7 Mon Sep 17 00:00:00 2001 From: emijrp Date: Thu, 7 Apr 2011 21:04:17 +0000 Subject: [PATCH] retrying when server is slow git-svn-id: https://wikiteam.googlecode.com/svn/trunk@22 31edc4fc-5e31-b4c4-d58b-c8bc928bcb95 --- dumpgenerator.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/dumpgenerator.py b/dumpgenerator.py index 7fd8f45..70c795b 100644 --- a/dumpgenerator.py +++ b/dumpgenerator.py @@ -151,7 +151,17 @@ def getXMLPage(config={}, title=''): params['limit'] = limit data = urllib.urlencode(params) req = urllib2.Request(url=config['domain'], data=data, headers=headers) - f = urllib2.urlopen(req) + try: + f = urllib2.urlopen(req) + except: + try: + print 'Sever is slow... Waiting some seconds and retrying...' + time.sleep(10) + f = urllib2.urlopen(req) + except: + print 'An error have occurred while retrieving', title + print 'Please, resume the dump, --resume' + sys.exit() xml = f.read() #if complete history, check if this page history has > limit edits, if so, retrieve all using offset if available