Commits

Jason Simeone committed caf9f21 Draft Merge

Merge

  • Participants
  • Parent commits 76edf64, 02ea7b3

Comments (0)

Files changed (1)

File pep381client/__init__.py

 from __future__ import with_statement
+
 import cPickle, os, xmlrpclib, time, urllib2, httplib, socket
+import xml.parsers.expat
 from xml.etree import ElementTree
-import xml.parsers.expat
+
 import sqlite
 
+
+# Set global socket timeout
+socket.setdefaulttimeout(30)
+
 # library config
 pypi = 'pypi.python.org'
 BASE = 'http://'+pypi
 SIMPLE = BASE + '/simple/'
-version = '1.5'
+version = '1.5.1'
 UA = 'pep381client/'+version
 
 # Helpers
 def now():
     return int(time.time())
 
+
 # Main class
 
 class Synchronization:
         if etag:
             h.putheader("If-none-match", etag)
         h.endheaders()
-        r = h.getresponse()
+
+        # If this returns a BadStatusLine, continue to retry, or skip it.
+        for i in range(4):
+            try:
+                r = h.getresponse()
+                break
+            except httplib.BadStatusLine:
+                print "BadStatusLine received; retrying"
+            except socket.timeout:
+                print "Connection timed out; retrying"
+        else:
+            print project, "could not be retrieved; skipping."
+            return
+
         if r.status == 304:
             # not modified, discard data
             r.read()