[issue35179] Limit max sendfile chunk to 0x7ffff000
STINNER Victor
report at bugs.python.org
Tue Nov 6 16:35:06 EST 2018
STINNER Victor <vstinner at redhat.com> 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 <report at bugs.python.org>
<https://bugs.python.org/issue35179>
_______________________________________
More information about the Python-bugs-list
mailing list