[Python-Dev] socket timeouts and httplib

Jeremy Hylton jeremy@alum.mit.edu
27 Jun 2003 15:55:44 -0400


There's a long standing, hard to reproduce bug report about httplib --
666219 -- that got me looking at the socket timeout code today.  The
most basic question I have is:  Do we expect the timeout code to work
with the httplib module?  The original timeoutsocket module uses httplib
as an example of its use.

I ask because some simple httplib tests aren't working as expected with
timeouts turned on.  I'm also curious because the socket documentation
says you shouldn't mix timeouts and makefile(), and httplib uses
makefile().

When I do have a small timeout and a slow server, I sometimes see an
error like this:

Traceback (most recent call last):
  File "/tmp/foo.py", line 14, in ?
    f = urllib.urlopen(url)
  File "/home/jeremy/src/python/dist/src/Lib/urllib.py", line 76, in
urlopen
    return opener.open(url)
  File "/home/jeremy/src/python/dist/src/Lib/urllib.py", line 181, in
open
    return getattr(self, name)(url)
  File "/home/jeremy/src/python/dist/src/Lib/urllib.py", line 297, in
open_http
    h.endheaders()
  File "/home/jeremy/src/python/dist/src/Lib/httplib.py", line 710, in
endheaders
    self._send_output()
  File "/home/jeremy/src/python/dist/src/Lib/httplib.py", line 595, in
_send_output
    self.send(msg)
  File "/home/jeremy/src/python/dist/src/Lib/httplib.py", line 562, in
send
    self.connect()
  File "/home/jeremy/src/python/dist/src/Lib/httplib.py", line 546, in
connect
    raise socket.error, msg
IOError: [Errno socket error] (114, 'Operation already in progress')

The socketmodule code is specifically looking for an EINPROGRESS return
from connect(), but I'm getting an EALREADY.  These are related but
distinct errors on Linux.

I'm not sure if I should file a bug report for code or documentation or
if it should somehow be obvious that I'm doing something wrong.

Jeremy