Message217156
> 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 |
|
Date |
User |
Action |
Args |
2014-04-25 08:40:55 | akira | set | recipients:
+ akira, gvanrossum, pitrou, giampaolo.rodola, christian.heimes, josiah.carlson, asvetlov, neologix, rosslagerwall, yselivanov, josh.r |
2014-04-25 08:40:55 | akira | set | messageid: <1398415255.88.0.974194439789.issue17552@psf.upfronthosting.co.za> |
2014-04-25 08:40:55 | akira | link | issue17552 messages |
2014-04-25 08:40:55 | akira | create | |
|