summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiampaolo Rodola <g.rodola@gmail.com>2014-04-30 22:49:10 +0000
committerGiampaolo Rodola <g.rodola@gmail.com>2014-04-30 22:49:10 +0000
commitffc5b407c04e7aa8b341d9ea484463420ea14a9c (patch)
treef41cacbce2b289435d302369ef9caa7139f43934
parentaa95b90c7f795c81ee73f7b4d0cbde1a13585a6d (diff)
downloadpysendfile-ffc5b407c04e7aa8b341d9ea484463420ea14a9c.tar.gz
update README
-rw-r--r--README34
1 files changed, 10 insertions, 24 deletions
diff --git a/README b/README
index 920cb3a..7dbb128 100644
--- a/README
+++ b/README
@@ -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