akira added the comment: > I'm confused. Why is "blocksize" necessary at all?
My guess, it may be used to implement socket.send()-based fallback. Its meaning could be the same as *length* parameter in shutil.copyfileobj The fallback is useful if os.sendfile doesn't exists or it doesn't accept given parameters e.g., if *file* is not mmap-like enough for os.sendfile. > > using os.path.getsize(file.name) looks risky to me > Why not fstat(fd) ? os.path.getsize(file.name) in msg217121 is a pseudo-code (as said in the comment) that expresses the intent that if *nbytes* parameter is not specified (None) then socket.sendfile should send bytes from the file until EOF is reached. In real code, if *nbytes is None*; I would just call os.sendfile repeatedly with a large constant *nbytes* parameter until os.sendfile returns 0 (meaning EOF) without asking the file size explicitly It assumes socket.sendfile doesn't specify its behaviour if the file size changes between the calls. The pseudo-code in msg217121 is my opinion about the public interface for socket.sendfile -- It is different from the one in the current socket-sendfile5.patch ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue17552> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com