Note that there are some explanatory texts on larger screens.

plurals
  1. POurlopen error 10045, 'address already in use' while downloading in Python 2.5 on Windows
    primarykey
    data
    text
    <p>I'm writing code that will run on Linux, OS X, and Windows. It downloads a list of approximately 55,000 files from the server, then steps through the list of files, checking if the files are present locally. (With SHA hash verification and a few other goodies.) If the files aren't present locally or the hash doesn't match, it downloads them.</p> <p>The server-side is plain-vanilla Apache 2 on Ubuntu over port 80.</p> <p>The client side works perfectly on Mac and Linux, but gives me this error on Windows (XP and Vista) after downloading a number of files:</p> <pre><code>urllib2.URLError: &lt;urlopen error &lt;10048, 'Address already in use'&gt;&gt; </code></pre> <p>This link: <a href="http://bytes.com/topic/python/answers/530949-client-side-tcp-socket-receiving-address-already-use-upon-connect" rel="nofollow noreferrer">http://bytes.com/topic/python/answers/530949-client-side-tcp-socket-receiving-address-already-use-upon-connect</a> points me to TCP port exhaustion, but "netstat -n" never showed me more than six connections in "TIME_WAIT" status, even just before it errored out.</p> <p>The code (called once for each of the 55,000 files it downloads) is this:</p> <pre><code>request = urllib2.Request(file_remote_path) opener = urllib2.build_opener() datastream = opener.open(request) outfileobj = open(temp_file_path, 'wb') try: while True: chunk = datastream.read(CHUNK_SIZE) if chunk == '': break else: outfileobj.write(chunk) finally: outfileobj = outfileobj.close() datastream.close() </code></pre> <p>UPDATE: I find by greping the log that it enters the download routine exactly 3998 times. I've run this multiple times and it fails at 3998 each time. Given that the linked article states that available ports are 5000-1025=3975 (and some are probably expiring and being reused) it's starting to look a lot more like the linked article describes the real issue. However, I'm still not sure how to fix this. Making registry edits is not an option.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload