MCPcopy Index your code
hub / github.com/python/cpython / sendfile

Method sendfile

Lib/socket.py:483–504  ·  view source on GitHub ↗

sendfile(file[, offset[, count]]) -> sent Send a file until EOF is reached by using high-performance os.sendfile() and return the total number of bytes which were sent. *file* must be a regular file object opened in binary mode. If os.sendfile() is not availa

(self, file, offset=0, count=None)

Source from the content-addressed store, hash-verified

481 "count must be a positive integer (got {!r})".format(count))
482
483 def sendfile(self, file, offset=0, count=None):
484 """sendfile(file[, offset[, count]]) -> sent
485
486 Send a file until EOF is reached by using high-performance
487 os.sendfile() and return the total number of bytes which
488 were sent.
489 *file* must be a regular file object opened in binary mode.
490 If os.sendfile() is not available (e.g. Windows) or file is
491 not a regular file socket.send() will be used instead.
492 *offset* tells from where to start reading the file.
493 If specified, *count* is the total number of bytes to transmit
494 as opposed to sending the file until EOF is reached.
495 File position is updated on return or also in case of error in
496 which case file.tell() can be used to figure out the number of
497 bytes which were sent.
498 The socket must be of SOCK_STREAM type.
499 Non-blocking sockets are not supported.
500 """
501 try:
502 return self._sendfile_use_sendfile(file, offset, count)
503 except _GiveupOnSendfile:
504 return self._sendfile_use_send(file, offset, count)
505
506 def _decref_socketios(self):
507 if self._io_refs > 0:

Callers

nothing calls this directly

Calls 2

_sendfile_use_sendMethod · 0.95

Tested by

no test coverage detected