title: receiving 401 errors inconsistently from python urllib2.urlopen call
body: <p>I have a python script that makes a series of url calls using urllib2.  The url is on http, but requires authentication.  I am currently trying to run the script such that it will make over 100 calls.  Every time I run the script, some calls fail with error code 401, and some pass.  All calls are for the same URL using the same username and password.  (Each time I run the script it is not the same calls that fail, sometimes the first call fails, sometimes it works.)</p>
  
  <p>Any ideas why a 401 might occur inconsistently?</p>
  
  <p>The error message printed to the screen is... </p>
  
  <p>Here is the method responsible for making the url call:</p>
  
  <pre><code>def simpleExecuteRequest(minX, minY, maxX, maxY, type) :
      url = 'http://myhost.com/geowebcache/rest/seed/mylayer.xml'
  
      msgTemplate = """&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;
      &lt;seedRequest&gt;
      &lt;name&gt;mylayer&lt;/name&gt;
      &lt;bounds&gt;
      &lt;coords&gt;
      &lt;double&gt;%s&lt;/double&gt;
      &lt;double&gt;%s&lt;/double&gt;
      &lt;double&gt;%s&lt;/double&gt;
      &lt;double&gt;%s&lt;/double&gt;
      &lt;/coords&gt;
      &lt;/bounds&gt;
      &lt;gridSetId&gt;nyc&lt;/gridSetId&gt;
      &lt;zoomStart&gt;0&lt;/zoomStart&gt;
      &lt;zoomStop&gt;10&lt;/zoomStop&gt;
      &lt;format&gt;image/png&lt;/format&gt;
      &lt;type&gt;%s&lt;/type&gt;
      &lt;threadCount&gt;1&lt;/threadCount&gt;
      &lt;/seedRequest&gt;
      """
  
      message = msgTemplate%(minX, minY, maxX, maxY, type)
      headers = { 'User-Agent' : "Python script", 'Content-type' : 'text/xml; charset="UTF-8"', 'Content-length': '%d' % len(message) }
      passwordManager = urllib2.HTTPPasswordMgrWithDefaultRealm()
      passwordManager.add_password(None, url, 'username', 'xxx')
      authenticationHandler = urllib2.HTTPBasicAuthHandler(passwordManager)
      proxyHandler = urllib2.ProxyHandler({})
      opener = urllib2.build_opener(proxyHandler, authenticationHandler)
      urllib2.install_opener(opener)    
  
      try :
          request = urllib2.Request(url, message, headers)
          response = urllib2.urlopen(request)
          content = response.read()
          print 'success'
      except IOError, e:
          print e
  </code></pre>
  
  <p>Sometimes the output will look like this...</p>
  
  <pre><code>&lt;urlopen error (10053, 'Software caused connection abort')&gt;
  success
  success
  &lt;urlopen error (10053, 'Software caused connection abort')&gt;
  &lt;urlopen error (10053, 'Software caused connection abort')&gt;
  ...
  </code></pre>
  
  <p>When run 1 minute later it might look like this...</p>
  
  <pre><code>success
  &lt;urlopen error (10053, 'Software caused connection abort')&gt;
  success
  success
  &lt;urlopen error (10053, 'Software caused connection abort')&gt;
  </code></pre>
  
  <p>On both runs the same series of inputs for min/max x/y and type were provided in the same order.
      ...</p>