Kaydet (Commit) 82259f2e authored tarafından Michael Stahl's avatar Michael Stahl

get-bugzilla-attachments-by-mimetype: add retry:

Sadly the Apache OO bugzilla is rather unreliable and connections time out
a lot; retry connections to work around that.
üst 18d1e196
...@@ -44,6 +44,17 @@ import xmlrpclib ...@@ -44,6 +44,17 @@ import xmlrpclib
from xml.dom import minidom from xml.dom import minidom
from xml.sax.saxutils import escape from xml.sax.saxutils import escape
def urlopen_retry(url):
maxretries = 3
for i in range(maxretries + 1):
try:
return urllib.urlopen(url)
except IOError as e:
print "caught IOError: ", e
if maxretries == i:
raise
print "retrying..."
def get_from_bug_url_via_xml(url, mimetype, prefix, suffix): def get_from_bug_url_via_xml(url, mimetype, prefix, suffix):
id = url.rsplit('=', 2)[1] id = url.rsplit('=', 2)[1]
print "id is", prefix, id, suffix print "id is", prefix, id, suffix
...@@ -51,7 +62,7 @@ def get_from_bug_url_via_xml(url, mimetype, prefix, suffix): ...@@ -51,7 +62,7 @@ def get_from_bug_url_via_xml(url, mimetype, prefix, suffix):
print "assuming", id, "is up to date" print "assuming", id, "is up to date"
else: else:
print "parsing", id print "parsing", id
sock = urllib.urlopen(url+"&ctype=xml") sock = urlopen_retry(url+"&ctype=xml")
dom = minidom.parse(sock) dom = minidom.parse(sock)
sock.close() sock.close()
attachmentid=1 attachmentid=1
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment