[issue18885] handle EINTR in the stdlib

Armin Rigo report at bugs.python.org
Sun Dec 1 03:15:02 CET 2013


Armin Rigo added the comment:

Modules/socketmodule.c is using a simple style to implement socket timeouts using select().  If I were to naively copy this style over to pure Python, it would work in current Pythons; I'd get occasionally an OSError(EINTR), which I would have presumably been annoyed with and am now catching properly.  Now if my working code was made to run with a select() modified as proposed, an EINTR would instead cause the program to fail more obscurely: its sockets occasionally -- and apparently without reason -- time out much earlier.  In that situation I would have a hard time finding the reason, particularly if running on an OS where the system select() doesn't spuriously return early with a timeout ("man select" on Linux guarantees this, for example).

Similarly, an existing program might rely on select() with an infinite timeout to only return when one of the descriptors is ready, particularly if called with only one or two descriptors.

Overall, I would far prefer the status quo over a change in the logic from one slightly-subtle situation to another differently slightly-subtle one.  I believe this would end up with programs that need to take special care about both kinds of subtlenesses just to run on two versions of Python.  I may be wrong, in this case sorry to take your time. :-)

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue18885>
_______________________________________


More information about the Python-bugs-list mailing list