STINNER Victor <[email protected]> added the comment:
> 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.
----------
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue35179>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com