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 kristjan.jonsson
Recipients kristjan.jonsson
Date 2011-03-30.12:17:21
SpamBayes Score 3.7359005e-14
Marked as misclassified No
Message-id <1301487442.2.0.0773643422684.issue11721@psf.upfronthosting.co.za>
In-reply-to
Content
I found this defect at PyCon 2011 after spending a lot of type fidgeting with ssl.  The test_ssl.py unittest was using timeout on accept sockets and it was working fine there, but not with the code I was working out.  Turns out that _ssl.py resets the timeout state of sockets, but not regular sockets.

In short:  If you have a socket with settimeout(1), then accept a connection on it, the new socket will have gettimeout()==None, but its state will still (internally) be non-blocking.  The attached script demonstrates the issue.

This is an issue with all versions of python from 2.5 upwards.

There are basically two things we can do to fis this:
1) retain gettimeout()=None but internally make sure we set the resulting socket to blocking mode
2) have the accepted socket inherit the timeout properties of the parent socket properly, and so inherit its timeout value too.

Number 2 is more in line with expected BSD socket behaviour that sockets at least inherit the non-blocking attribute of their parent socket.
History
Date User Action Args
2011-03-30 12:17:22kristjan.jonssonsetrecipients: + kristjan.jonsson
2011-03-30 12:17:22kristjan.jonssonsetmessageid: <1301487442.2.0.0773643422684.issue11721@psf.upfronthosting.co.za>
2011-03-30 12:17:21kristjan.jonssonlinkissue11721 messages
2011-03-30 12:17:21kristjan.jonssoncreate