New submission from Julia Dolgova:

I'm using python 2.7. My system is windows 7(64-bit). I also use proxy.
urllib2.urlopen usually implements 0,2..1sec but sometimes sends a strange UDP 
to 137 port (netbios-ns) of the remote server, waits 4..6 sec. and then sends 

If I disable Netbios over TCP/IP in my system settings no UDP to 137 port is 
sent, but urlopen still implements 4..6sec.

I've found out that the delay happens in 
called by socket.getfqdn(HostName)
called by urllib.proxy_bypass_registry(HostName)
called by urllib.proxy_bypass(HostName)
called by urllib2.ProxyHandler.proxy_open 


"nslookup" works quickly in my computer

I suppose the problem is that the hostname is passed into gethostbyaddr instead 
of IP

If I add an IP-verification of the string before socket.getfqdn() call in 
        socket.inet_aton(rawHost) #### I added this operator
        fqdn = socket.getfqdn(rawHost)
        if fqdn != rawHost:
except socket.error:

then no delay happens.

My proposal is to make an IP-verification in urllib.proxy_bypass_registry() or 
to add an opportunity for a programmer to refuse a proxy bypass attempt

components: Library (Lib), Windows
messages: 259190
nosy: juliadolgova, paul.moore, steve.dower, tim.golden, zach.ware
priority: normal
severity: normal
status: open
title: urllib2 initiate irregular call to gethostbyaddr
type: performance
versions: Python 2.7

Python tracker <>
Python-bugs-list mailing list

Reply via email to