Python urllib2.urlopen is much slower in Windows 7 when querying a local host

I am running python code for the first time on a computer running Windows 7 and noticed that this HTTP request for my local server is much slower than before:

result = urllib2.urlopen ("http: // localhost: 3000 / somepath") .read ()

This is called multiple times, and each time, instead of returning immediately, it takes about a second. If I replaced localhost with 127.0.0.1, it immediately returns, as before (it was on Mac OS).

There is nothing to worry about, but it was curious about the reason.

If DNS, why is it not cached?

+5
source share
1 answer

Per yotam.shacham, , Windows hosts:

127.0.0.1 localhost

Windows 7 `hosts

%SystemRoot%\system32\drivers\etc\hosts

%SystemRoot% C:\WINDOWS

+1

All Articles