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 vstinner
Recipients asvetlov, giampaolo.rodola, vstinner, yselivanov
Date 2018-11-06.21:35:06
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1541540106.6.0.788709270274.issue35179@psf.upfronthosting.co.za>
In-reply-to
Content
> In that case I think asyncio's sendfile() should simply do the math to transmit that many bytes by taking into account that os.sendfile() may return less bytes than requested.

The internal sendfile() implementation in asyncio already loops until all bytes are sent. Extract of unix_events.py:

    def _sock_sendfile_native_impl(self, fut, registered_fd, sock, fileno,
                                   offset, count, blocksize, total_sent):
        ...
        try:
            sent = os.sendfile(fd, fileno, offset, blocksize)
        except (BlockingIOError, InterruptedError):
            ...
        else:
            if sent == 0:
                # EOF
                self._sock_sendfile_update_filepos(fileno, offset, total_sent)
                fut.set_result(total_sent)
            else:
                offset += sent
                total_sent += sent
                self.add_writer(fd, self._sock_sendfile_native_impl, fut, ...)

asyncio doesn't need to be modified.
History
Date User Action Args
2018-11-06 21:35:06vstinnersetrecipients: + vstinner, giampaolo.rodola, asvetlov, yselivanov
2018-11-06 21:35:06vstinnersetmessageid: <1541540106.6.0.788709270274.issue35179@psf.upfronthosting.co.za>
2018-11-06 21:35:06vstinnerlinkissue35179 messages
2018-11-06 21:35:06vstinnercreate