Skip to content

Commit

Permalink
retrying getting json in case of failure
Browse files Browse the repository at this point in the history
  • Loading branch information
volpino committed Aug 7, 2012
1 parent f2fae42 commit b8e8e85
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion pywc_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,16 @@ def find_revision_id(title, revision, lang, startid=None):

url = api_base + '?' + urllib.urlencode(options)
logging.info(url)
result = simplejson.load(urllib.urlopen(url))
result = None
i = 0
while result is None and i < 10:
i += 1
try:
result = simplejson.load(urllib.urlopen(url))
except Exception:
logging.error("Can't get JSON from %s", url)
if result is None:
return None

if revision < 500:
pages = result["query"]["pages"]
Expand Down

0 comments on commit b8e8e85

Please sign in to comment.