[issue17552] socket.sendfile()

Giampaolo Rodola' report at bugs.python.org
Tue Apr 22 04:13:21 CEST 2014


Giampaolo Rodola' added the comment:

> Instead of returning [...] you could specify `no_fallback=False` that 
> could be set to `True` to assert that the fallback is not used
> [...] and return the number of bytes sent.

Good idea, thanks, that is much better indeed. Updated patch is in attachment.


> [...] file.tell() may be changed by something else that uses 
> the same file descriptor? What happens if the file grows?

I would say that is a use case we should explicitly not support as it probably implies you're doing something you're not supposed to. 


> If possible always include the number of bytes sent in any error that is raised.

That's similar to my recent (rejected) proposal for socket.sendall():
https://mail.python.org/pipermail/python-ideas/2014-April/027689.html
IMO the patch as it stands is fine as you can determine the number of bytes which were sent either by using the function return value or file.tell() (in case of error).
Also, updating the file offset on exit makes the sendfile() implementation behave exactly like send().

----------
Added file: http://bugs.python.org/file34997/socket-sendfile4.patch

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


More information about the Python-bugs-list mailing list