teenaPython ports of useful syscalls, using asynchronous I/O | |
Download |
teena Ranking & Summary
Advertisement
- License:
- MIT/X Consortium Lic...
- Price:
- FREE
- Publisher Name:
- Zachary Voase
- Publisher web site:
- http://github.com/disturbyte/
teena Tags
teena Description
teena is a Python module that aims to be a collection of ports of UNIX and Linux syscalls to pure Python, with an emphasis on performance and correctness.Developer commentsWindows support is not a primary concern—I’m initially targeting only POSIX-compliant operating systems. The library uses Tornado to do efficient asynchronous I/O.The first version of this library contains implementations of tee and splice which operate on files, sockets, and file descriptors. There’s also a Capture class which behaves like StringIO, but it has a fileno() and so can be used where a real file descriptor is needed.ExampleI’ll demonstrate how to capture the result of an HTTP request, whilst efficiently streaming the response to stderr.Do the necessary imports:>>> from contextlib import closing>>> import teena>>> import os>>> import sys>>> import urllib2Create a teena.Capture() object to capture the output:>>> capture = teena.Capture()Open a connection using urllib2.urlopen(). This connection object has an associated file descriptor, so you can pass it directly into tee():>>> with closing(urllib2.urlopen('http://whatthecommit.com/index.txt')) as conn:... teena.tee(conn, (sys.stderr, capture.input))This really should not take 19 minutes to build.>>> print repr(capture.getvalue())'This really should not take 19 minutes to build.\n'Installationpip install teenaProduct's homepage
teena Related Software