diff options
author | Andrew Svetlov <andrew.svetlov@gmail.com> | 2018-01-16 17:59:34 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-16 17:59:34 (GMT) |
commit | 6b5a27975a415108a5eac12ee302bf2b3233f4d4 (patch) | |
tree | 09e3233c5c9c9b269c5cc47a0ed97a151280daac /Doc | |
parent | c495e799ed376af91ae2ddf6c4bcc592490fe294 (diff) | |
download | cpython-6b5a27975a415108a5eac12ee302bf2b3233f4d4.zip cpython-6b5a27975a415108a5eac12ee302bf2b3233f4d4.tar.gz cpython-6b5a27975a415108a5eac12ee302bf2b3233f4d4.tar.bz2 |
bpo-32410: Implement loop.sock_sendfile() (#4976)
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/library/asyncio-eventloop.rst | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/Doc/library/asyncio-eventloop.rst b/Doc/library/asyncio-eventloop.rst index 4fbbcd8..e63180b 100644 --- a/Doc/library/asyncio-eventloop.rst +++ b/Doc/library/asyncio-eventloop.rst @@ -701,6 +701,36 @@ Low-level socket operations :meth:`AbstractEventLoop.create_server` and :func:`start_server`. +.. coroutinemethod:: AbstractEventLoop.sock_sendfile(sock, file, \ + offset=0, count=None, \ + *, fallback=True) + + Send a file using high-performance :mod:`os.sendfile` if possible + and return the total number of bytes which were sent. + + Asynchronous version of :meth:`socket.socket.sendfile`. + + *sock* must be non-blocking :class:`~socket.socket` of + :const:`socket.SOCK_STREAM` type. + + *file* must be a regular file object opened in binary mode. + + *offset* tells from where to start reading the file. If specified, + *count* is the total number of bytes to transmit as opposed to + sending the file until EOF is reached. File position is updated on + return or also in case of error in which case :meth:`file.tell() + <io.IOBase.tell>` can be used to figure out the number of bytes + which were sent. + + *fallback* set to ``True`` makes asyncio to manually read and send + the file when the platform does not support the sendfile syscall + (e.g. Windows or SSL socket on Unix). + + Raise :exc:`RuntimeError` if the system does not support + *sendfile* syscall and *fallback* is ``False``. + + .. versionadded:: 3.7 + Resolve host name ----------------- |