diff options
-rwxr-xr-x | git-bz | 24 |
1 files changed, 22 insertions, 2 deletions
@@ -889,6 +889,12 @@ def get_connection(host, https): return connections[identifier] +def kill_connection(host, https): + identifier = (host, https) + if identifier in connections: + del connections[identifier] + + class BugServer(object): def __init__(self, host, path, https, auth_user=None, auth_password=None): self.host = host @@ -918,10 +924,24 @@ class BugServer(object): url = self.path + url seen_urls = [] + retries = 0 connection = get_connection(self.host, self.https) while True: - connection.request(method, url, data, headers) - response = connection.getresponse() + + # BMO seems to generate some "bad status line" exception intermittently. + try: + connection.request(method, url, data, headers) + response = connection.getresponse() + except httplib.BadStatusLine: + retries = retries + 1 + print "Got bad status line - retrying..." + connection.close() + kill_connection(self.host, self.https) + time.sleep(2) + connection = get_connection(self.host, self.https) + continue + retries = 0 + seen_urls.append(url) # Redirect status codes: |