[Patches] [ python-Patches-1628205 ] socket.readline() interface doesn't handle EINTR properly

SourceForge.net noreply at sourceforge.net
Sun Jan 7 19:24:24 CET 2007


Patches item #1628205, was opened at 2007-01-04 21:37
Message generated for change (Comment added) made by orenti
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1628205&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Modules
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Maxim Sobolev (sobomax)
Assigned to: Nobody/Anonymous (nobody)
Summary: socket.readline() interface doesn't handle EINTR properly

Initial Comment:
The socket.readline() interface doesn't handle EINTR properly. Currently, when EINTR received exception is not handled and all data that has been in the buffer is lost. There is no way to recover that data from the code that uses the interface.

Correct behaviour would be to catch EINTR and restart recv(). Patch is attached.

Following is the real world example of how it affects httplib module:

  File "/usr/local/lib/python2.4/xmlrpclib.py", line 1096, in __call__
    return self.__send(self.__name, args)
  File "/usr/local/lib/python2.4/xmlrpclib.py", line 1383, in __request
    verbose=self.__verbose
  File "/usr/local/lib/python2.4/xmlrpclib.py", line 1131, in request
    errcode, errmsg, headers = h.getreply()
  File "/usr/local/lib/python2.4/httplib.py", line 1137, in getreply
    response = self._conn.getresponse()
  File "/usr/local/lib/python2.4/httplib.py", line 866, in getresponse
    response.begin()
  File "/usr/local/lib/python2.4/httplib.py", line 336, in begin
    version, status, reason = self._read_status()
  File "/usr/local/lib/python2.4/httplib.py", line 294, in _read_status
    line = self.fp.readline()
  File "/usr/local/lib/python2.4/socket.py", line 325, in readline
    data = recv(1)
error: (4, 'Interrupted system call')

-Maxim

----------------------------------------------------------------------

Comment By: Oren Tirosh (orenti)
Date: 2007-01-07 18:24

Message:
Logged In: YES 
user_id=562624
Originator: NO

You may have encountered this on sockets but *all* Python I/O does not
handle restart on EINTR. 

The right place to fix this is probably in C, not the Python library. The
places where an I/O operation could be interrupted are practically anywhere
the GIL is released. This kind of change is likely to be controversial.


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1628205&group_id=5470


More information about the Patches mailing list