Welcome, guest | Sign In | My Account | Store | Cart

Notice! PyPM is being replaced with the ActiveState Platform, which enhances PyPM’s build and deploy capabilities. Create your free Platform account to download ActivePython or customize Python with the packages you require and get automatic updates.

Download
ActivePython
INSTALL>
pypm install iowait

How to install iowait

  1. Download and install ActivePython
  2. Open Command Prompt
  3. Type pypm install iowait
 Python 2.7Python 3.2Python 3.3
Windows (32-bit)
0.1 Available View build log
0.1 Available View build log
Windows (64-bit)
0.1 Available View build log
0.1 Available View build log
Mac OS X (10.5+)
0.1 Available View build log
0.1 Available View build log
Linux (32-bit)
0.1 Available View build log
0.1 Available View build log
Linux (64-bit)
0.1 Available View build log
0.1 Available View build log
0.1 Available View build log
 
License
GNU LGPL v3
Depended by
Imports
Lastest release
version 0.1 on Jan 26th, 2011

Different operating systems provide different ways to wait for I/O completion events: there's select(), poll(), epoll() and kqueue(). For cross-platform applications it can be a pain to support all this system functions, especially because each one provides a different interface.

IOWait solves this problem by providing a unified interface and using always the best and faster function available in the platform. Its only limitation is that, on Windows, it only works for sockets.

This library is compatible both with Python 2 and 3.

Example

Here is an usage example. First, we need to create a pair of sockets:

>>> import socket
>>> a, b = socket.socketpair()

Then we create a IOWait object. This object is essentially a wrapper around a system function (such as select() or poll()), but exposes always the same methods and behaves always the same.

>>> from iowait import IOWait
>>> waitobj = IOWait()

Now we can watch the first socket for read events in this way:

>>> waitobj.watch(a, read=True)

We send some data over the other socket:

>>> b.sendall('this is a test')

Calling wait() on the IOWait object will tell us that the socket a is ready to be read:

>>> events = waitobj.wait()
>>> events #doctest:+ELLIPSIS
[(<socket object, ...>, True, False)]

The return value of wait() is a list of three-tuples in the format: (file, read, write), where file is a file-like object, read and write tell respectively whether the file is ready to be read or written.

Once all the data has been read, the next call to wait() will block forever, unless a timeout is specified:

>>> a.recv(14)
'this is a test'
>>> waitobj.wait(0.0)
[]

Subscribe to package updates

Last updated Jan 26th, 2011

Download Stats

Last month:1

What does the lock icon mean?

Builds marked with a lock icon are only available via PyPM to users with a current ActivePython Business Edition subscription.

Need custom builds or support?

ActivePython Enterprise Edition guarantees priority access to technical support, indemnification, expert consulting and quality-assured language builds.

Plan on re-distributing ActivePython?

Get re-distribution rights and eliminate legal risks with ActivePython OEM Edition.