From 8d92019665ee13288f6483725c8cedd318812566 Mon Sep 17 00:00:00 2001 From: Bobby Holley Date: Mon, 16 Aug 2010 23:51:45 -0400 Subject: Workaround for the "bad status line" error. Not the most elegant thing in the world. --- git-bz | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/git-bz b/git-bz index b480b00..3e9268d 100755 --- a/git-bz +++ b/git-bz @@ -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: -- cgit v1.2.3