Skip to main content

A Python interface to sendfile(2)

Project description


A python interface to sendfile(2) system call.


$ sudo install


$ easy_install pysendfile

Supported platforms

  • Linux
  • OSX
  • FreeBSD
  • Dragon Fly BSD
  • SunOS
  • AIX (non properly tested)

Python versions from 2.5 to 3.3 by using a single code base.

Example usage

import socket
import errno
from sendfile import sendfile

file = open("somefile", "rb")
sock = socket.socket()
sock.connect(("", 8021))
offset = 0

while 1:
        sent = sendfile(sock.fileno(), file.fileno(), offset, 4096)
    except OSError, err:
        if err.errno == (errno.EAGAIN, errno.EBUSY):  # retry
        if sent == 0:
            break  # done
        offset += sent

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page