diff options
author | Giampaolo Rodola <g.rodola@gmail.com> | 2014-04-30 22:49:10 +0000 |
---|---|---|
committer | Giampaolo Rodola <g.rodola@gmail.com> | 2014-04-30 22:49:10 +0000 |
commit | ffc5b407c04e7aa8b341d9ea484463420ea14a9c (patch) | |
tree | f41cacbce2b289435d302369ef9caa7139f43934 | |
parent | aa95b90c7f795c81ee73f7b4d0cbde1a13585a6d (diff) | |
download | pysendfile-ffc5b407c04e7aa8b341d9ea484463420ea14a9c.tar.gz |
update README
-rw-r--r-- | README | 34 |
1 files changed, 10 insertions, 24 deletions
@@ -1,27 +1,20 @@ -=========== Quick links =========== * Home page: http://code.google.com/p/pysendfile -* Download: http://code.google.com/p/pysendfile/downloads/list +* Download: https://pypi.python.org/pypi/pysendfile -===== About ===== A python interface to sendfile(2) system call. +Note: as of Python 3.3 you can simply use `os.sendfile() <https://docs.python.org/3/library/os.html#os.sendfile>`_ instead. -======= Install ======= -$ sudo setup.py install - -...or: +$ pip install pysendfile -$ easy_install pysendfile - -=================== Supported platforms =================== @@ -32,31 +25,24 @@ Supported platforms * SunOS * AIX (non properly tested) -Python versions from 2.5 to 3.3 by using a single code base. +Python versions from 2.5 to 3.4 by using a single code base. -============= Example usage ============= :: import socket - import errno from sendfile import sendfile file = open("somefile", "rb") + blocksize = os.path.getsize("somefile") sock = socket.socket() sock.connect(("127.0.0.1", 8021)) offset = 0 - while 1: - try: - sent = sendfile(sock.fileno(), file.fileno(), offset, 4096) - except OSError, err: - if err.errno == (errno.EAGAIN, errno.EBUSY): # retry - continue - raise - else: - if sent == 0: - break # done - offset += sent + while True: + sent = sendfile(sock.fileno(), file.fileno(), offset, blocksize) + if sent == 0: + break # EOF + offset += sent |