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 neologix
Recipients akira, asvetlov, christian.heimes, giampaolo.rodola, gvanrossum, josh.r, josiah.carlson, neologix, pitrou, rosslagerwall, yselivanov
Date 2014-04-24.07:02:01
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <CAH_1eM2hQnWnMxmhcS=MR_7a+frFgEK14X5Pt2zzKLu6q6XTxQ@mail.gmail.com>
In-reply-to <1398273998.89.0.0627946596294.issue17552@psf.upfronthosting.co.za>
Content
>> A useful parameter instead would be to support sending only part of the file,
>> so adding a count argument.
>
> Have you read my patch? This is already provided by the "offset" parameter.

Of course I read your patch ;-)
I mean I'd like a parameter for the offset, and another one for the
number of bytes to send, like in Java's version (and sendfile(), see
below).

>> I really don't like the blocksize argument.
>> I've *never* seen code which explicitly uses a blocksize
>
> Both sendfile() and TransmitFile provide a "blocksize" parameter for very good reasons therefore it seems natural that an API built on top of them exposes the same parameter as well.

No, they expose a *count* parameter:
http://linux.die.net/man/2/sendfile
"""
ssize_t sendfile(int out_fd, int in_fd, off_t *offset, size_t count);
count is the number of bytes to copy between the file descriptors.
"""

You're mixing up blocksize, which is the maximum number of bytes to
transfer in one syscall and only makes sense in the context of
repeated syscalls, and count, which is the total amount of data you
want the function to transfer.
No sensible sendfile-like API exposes a maximum "blocksize" to send at
once, since the goal is to limit copies and system calls: you just
pass a source and destination FD, a starting offset, and a number of
bytes to transfer, and the syscall takes care of the rest.

Here, you basically implement sendall() on top of sendfile() (in
pseudo-code, using a buffer instead of a file and not taking into
account short writes but the idea if the same):

while <remaining data to send>:
    socket.sendfile(data[offset:offset+chunksize)

The way it's supposed to be used is simply:
socket.sendfile(data[offset:offset+count])

That's how everyone one uses sendfile(), that's how Java exposes it,
and that's IMO how it should be exposed.

To sum up, I think there's a fundamental confusion between blocksize
and count in this API: that's what I've been saying since the
beginning of this thread: if you disagree, that's OK, I just want to
make sure we're talking about the same thing ;-)
History
Date User Action Args
2014-04-24 07:02:02neologixsetrecipients: + neologix, gvanrossum, pitrou, giampaolo.rodola, christian.heimes, josiah.carlson, asvetlov, akira, rosslagerwall, yselivanov, josh.r
2014-04-24 07:02:02neologixlinkissue17552 messages
2014-04-24 07:02:01neologixcreate