This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Yaniv.Aknin
Recipients Yaniv.Aknin, exarkun, neologix, nvetoshkin, pitrou
Date 2010-04-08.06:06:11
SpamBayes Score 1.6653345e-16
Marked as misclassified No
Message-id <1270706776.75.0.748897622839.issue7978@psf.upfronthosting.co.za>
In-reply-to
Content
First, let me cast my vote in favour of leaving select() itself alone, it's excessive to fix this issue with changing select().

Second, while exarkun's comments are accurate, I understand where pitrou is coming from. EINTR is not a pathological case, but it's not commonplace, either. I believe that on modern Unices (I tried Linux and OpenSolaris), the default handler for SIGCHLD will restart interrupted calls. By default, SIGUSR1 and most sane others, will kill the process anyway. So I can understand the purity of the argument that if a process sets a signal handler, it might just as well set SA_RESTART and be done with it.

That said, Imagine I write a forking server with SocketServer which sets a signal handler for SIGCHLD, and I don't set SA_RESTART because I don't think I need to. I believe this is a valid real-world scenario where (a) I don't expect an EINTER-related exception to be raised from SocketServer, (b) SocketServer can actually do something about it, and (c) I doubt the old EINTR behaviour is relied upon by anyone (now I'm /certain/ someone relying on this will pop-up...). I think its a safer bet on behalf of SocketServer (and subprocess, etc) to use something like untilConcludes.

If we agree so far, I believe that an implementation of untilConcludes *should* be added to stdlib ("signal.restartable_call", anyone?). If people agree, I'd be happy to produce the patch (trunk+py3k, doc+test). Other than SocketServer and subprocess, anything else that should use "untilConcludes"?

Finally, to answer pitrou's second question, I'm pretty sure untilConcludes as presented will not hurt other signal handlers. The interrupt handler will be executed before returning to untilConcludes' loop and manually restarting the call, so KeyboardInterrupt (or anything else signalistic) will behave as expected.

I'm attaching a toy 3.x program to play with select() and EINTR, I used it in writing this comment. Gee, it even has an OptionParser CLI to save you some commenting-out.
History
Date User Action Args
2010-04-08 06:06:17Yaniv.Akninsetrecipients: + Yaniv.Aknin, exarkun, pitrou, nvetoshkin, neologix
2010-04-08 06:06:16Yaniv.Akninsetmessageid: <1270706776.75.0.748897622839.issue7978@psf.upfronthosting.co.za>
2010-04-08 06:06:14Yaniv.Akninlinkissue7978 messages
2010-04-08 06:06:12Yaniv.Aknincreate