When fetching metadata from a binhost, reconnect if the http server closes the connec...
authorZac Medico <zmedico@gentoo.org>
Thu, 4 Jan 2007 03:11:39 +0000 (03:11 -0000)
committerZac Medico <zmedico@gentoo.org>
Thu, 4 Jan 2007 03:11:39 +0000 (03:11 -0000)
svn path=/main/trunk/; revision=5458

pym/getbinpkg.py

index 729525c040de49e533fe127ebd1ff7faba739dd3..058919bf1fec29d396cbf6712259fffc8003259c 100644 (file)
@@ -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: