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)
| 472 | "count must be a positive integer (got {!r})".format(count)) |
| 473 | |
| 474 | def sendfile(self, file, offset=0, count=None): |
| 475 | """sendfile(file[, offset[, count]]) -> sent |
| 476 | |
| 477 | Send a file until EOF is reached by using high-performance |
| 478 | os.sendfile() and return the total number of bytes which |
| 479 | were sent. |
| 480 | *file* must be a regular file object opened in binary mode. |
| 481 | If os.sendfile() is not available (e.g. Windows) or file is |
| 482 | not a regular file socket.send() will be used instead. |
| 483 | *offset* tells from where to start reading the file. |
| 484 | If specified, *count* is the total number of bytes to transmit |
| 485 | as opposed to sending the file until EOF is reached. |
| 486 | File position is updated on return or also in case of error in |
| 487 | which case file.tell() can be used to figure out the number of |
| 488 | bytes which were sent. |
| 489 | The socket must be of SOCK_STREAM type. |
| 490 | Non-blocking sockets are not supported. |
| 491 | """ |
| 492 | try: |
| 493 | return self._sendfile_use_sendfile(file, offset, count) |
| 494 | except _GiveupOnSendfile: |
| 495 | return self._sendfile_use_send(file, offset, count) |
| 496 | |
| 497 | def _decref_socketios(self): |
| 498 | if self._io_refs > 0: |
nothing calls this directly
no test coverage detected