Message116426
I've never used socket.socket.makefile so I'm not sure, but its documentation says:
> The socket must be in blocking mode (it can not have a timeout).
If the statement is there because EAGAIN/EWOULDBLOCK were originally raised then it should be removed, otherwise I question whether makefile() is actually supposed to support non-blocking sockets in the first place.
IMO, I think it's a matter of figuring out whether makefile() should provide a socket-like behavior or a file like-behavior first.
In the first case I would expect all errors be raised as if I'm dealing with a common socket, otherwise they should be silenced/handled internally or makefile() just fail immediately as there's not such thing as "non-blocking files".
> Instead, readinto() should detect the blocking condition (EAGAIN / EWOULDBLOCK) and
> return None (same for write(), I imagine).
io.RawIOBase.readinto doc says:
> Read up to len(b) bytes into bytearray b and return the number of bytes read.
...so returning 0 instead of None looks more natural to me.
Same for write, also because:
>>> open('xxx', 'w').write('')
0
I've also noticed that socket.SocketIO.readinto has a while loop which continues in case of EINTR and that's something which should be removed in case makefile() actually intends to support non-blocking sockets. |
|
Date |
User |
Action |
Args |
2010-09-14 23:19:19 | giampaolo.rodola | set | recipients:
+ giampaolo.rodola, amaury.forgeotdarc, pitrou, benjamin.peterson, stutzbach |
2010-09-14 23:19:19 | giampaolo.rodola | set | messageid: <1284506359.34.0.715812188339.issue9854@psf.upfronthosting.co.za> |
2010-09-14 23:19:17 | giampaolo.rodola | link | issue9854 messages |
2010-09-14 23:19:16 | giampaolo.rodola | create | |
|