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, gregory.p.smith, neologix, nvetoshkin, pitrou, spiv
Date 2010-04-09.09:24:27
SpamBayes Score 6.661338e-16
Marked as misclassified No
Message-id <>
pitrou, re. test code: I actually started with the test code, so that part is done.

I opted to use a forked SocketServer rather than threads. I'm not an expert on the low-level details of a multi-threaded process receiving threads, but it seems to me like there's a chicken and egg issue here: suppose we have threadA (blocking on select()) and threadB (managing the test and doing something like os.kill(os.getpid(), SIGFOO). I think by definition the thread running when the signal is received is threadB (since it sent the signal), and I'm not sure threadA will be interrupted properly that way (threads are sneaky, now aren't they). So I cleaned up a bit, split it to a base test case and concrete test cases, and added a separate test case which uses os.fork() rather than threads and tests that way.

The attached patch is against recent py3k and includes both neologix's patch (adapted to py3k) and the added test code. If this looks good, I'll easily backport it to 2.x/trunk.

spiv, re. handling timeout in select: You're very right, and I'm not sure how we should handle it if we want to take the "untilConcludes" code that is currently shared between and and move it outside. For subprocess' and socketserver's specific cases, the naive implementation which doesn't handle timeouts is OK, because they don't use the timeout parameter anyway.

Moving it outside warrants more discussion. Remember this isn't just about select() - it's a general user-space-restarter for any of the myriad of "slow" system calls that might be interrupted. There is some tension between elegance and even feasibility of correct implementation vs. the wrapper hiding functionality of some of these system calls. You could argue that if the user of the wrapper is unhappy about the lost functionality, they can make their own wrapper. 

Unless we can reach a resolution quickly, my gut feeling is that the current patch should be applied as-is and this issue be closed. A new issue along the lines of "Extract duplicate interruption-restart code to a relevant module and review stdlib for unprotected select() calls" should be opened instead. Your thoughts?
Date User Action Args
2010-04-09 09:24:35Yaniv.Akninsetrecipients: + Yaniv.Aknin, gregory.p.smith, spiv, exarkun, pitrou, nvetoshkin, neologix
2010-04-09 09:24:33Yaniv.Akninsetmessageid: <>
2010-04-09 09:24:31Yaniv.Akninlinkissue7978 messages
2010-04-09 09:24:29Yaniv.Aknincreate