From: Zac Medico Date: Thu, 4 Jan 2007 03:11:39 +0000 (-0000) Subject: When fetching metadata from a binhost, reconnect if the http server closes the connec... X-Git-Tag: v2.1.2~162 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=20df969c2cda9a0b524e3f18ec2a211be7a1722f;p=portage.git When fetching metadata from a binhost, reconnect if the http server closes the connection before sending a valid response. Thanks to ranger for reporting. svn path=/main/trunk/; revision=5458 --- diff --git a/pym/getbinpkg.py b/pym/getbinpkg.py index 729525c04..058919bf1 100644 --- a/pym/getbinpkg.py +++ b/pym/getbinpkg.py @@ -522,8 +522,20 @@ def dir_get_metadata(baseurl, conn=None, chunk_size=3000, verbose=1, usingcache= (x not in metadata[baseurl]["data"].keys())): sys.stderr.write(yellow("x")) metadata[baseurl]["modified"] = 1 - myid = file_get_metadata(baseurl+"/"+x, conn, chunk_size) - + for retry in xrange(3): + try: + myid = file_get_metadata( + "/".join((baseurl.rstrip("/"), x.lstrip("/"))), + conn, chunk_size) + break + except httplib.BadStatusLine: + # Sometimes this error is thrown from conn.getresponse() in + # make_http_request(). The docstring for this error in + # httplib.py says "Presumably, the server closed the + # connection before sending a valid response". + conn, protocol, address, params, headers = create_conn( + baseurl) + if myid[0]: metadata[baseurl]["data"][x] = make_metadata_dict(myid) elif verbose: