diff options
author | Bobby Holley <bobbyholley@gmail.com> | 2010-08-16 23:51:45 -0400 |
---|---|---|
committer | Stef Walter <stefw@gnome.org> | 2012-09-18 10:11:47 +0200 |
commit | 8d92019665ee13288f6483725c8cedd318812566 (patch) | |
tree | 1c1e743fb5d7a226dd66c77b9a434e1054fcdbc1 | |
parent | ef4f2df124459706f9e826038b47b57d49592829 (diff) |
Workaround for the "bad status line" error. Not the most elegant thing in the world.
-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: |