socket timeout error?

Jaap Spies j.spies at hccnet.nl
Mon Apr 17 14:38:18 EDT 2006


Hi,

Running Fedora Core 4: Python 2.4.3 and Python 2.4.1.
I'm getting:
IOError: [Errno socket error] (2, 'No such file or directory')
all the time.

Trying to track down this problem:

Python 2.4.1 (#1, May 16 2005, 15:19:29)
[GCC 4.0.0 20050512 (Red Hat 4.0.0-5)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
 >>> import socket
 >>> socket.getdefaulttimeout()
 >>> import urllib
 >>> urllib.urlopen('http://www.python.org')
Traceback (most recent call last):
   File "<stdin>", line 1, in ?
   File "urllib.py", line 77, in urlopen
     return opener.open(url)
   File "urllib.py", line 180, in open
     return getattr(self, name)(url)
   File "urllib.py", line 296, in open_http
     h.endheaders()
   File "/usr/lib/python2.4/httplib.py", line 794, in endheaders
     self._send_output()
   File "/usr/lib/python2.4/httplib.py", line 675, in _send_output
     self.send(msg)
   File "/usr/lib/python2.4/httplib.py", line 642, in send
     self.connect()
   File "/usr/lib/python2.4/httplib.py", line 610, in connect
     socket.SOCK_STREAM):
IOError: [Errno socket error] (2, 'No such file or directory')
 >>> socket.setdefaulttimeout(0.1)
 >>> socket.getdefaulttimeout()
0.10000000000000001
 >>> urllib.urlopen('http://www.python.org')
<addinfourl at -1209281748 whose fp = <socket._fileobject object at 
0xb7bc3f0c>>>>> socket.setdefaulttimeout(0.01)
 >>> urllib.urlopen('http://www.python.org')
Traceback (most recent call last):
   File "<stdin>", line 1, in ?
   File "urllib.py", line 77, in urlopen
     return opener.open(url)
   File "urllib.py", line 180, in open
     return getattr(self, name)(url)
   File "urllib.py", line 296, in open_http
     h.endheaders()
   File "/usr/lib/python2.4/httplib.py", line 794, in endheaders
     self._send_output()
   File "/usr/lib/python2.4/httplib.py", line 675, in _send_output
     self.send(msg)
   File "/usr/lib/python2.4/httplib.py", line 642, in send
     self.connect()
   File "/usr/lib/python2.4/httplib.py", line 626, in connect
     raise socket.error, msg
IOError: [Errno socket error] timed out
 >>> socket.setdefaulttimeout(0.05)
 >>> urllib.urlopen('http://www.python.org')
<addinfourl at -1209306484 whose fp = <socket._fileobject object at 
0xb7eb9cdc>>>>>

Seems a timeout of 0.01 is to small and a timeout >= 0.05 is working.

What is the real problem here?

Jaap



More information about the Python-list mailing list