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