win32: emulating select() on pipes

Bryan Olson fakeaddress at nowhere.org
Tue Mar 18 06:53:28 EDT 2008


gangesmaster wrote:
> i'm trying to figure out if a pipe on win32 has data for me to read.
[...]

> does anyone know of a better way to tell if data is available on a
> pipe?
> something that blocks until data is available or the timeout is
> elapsed,

In Win32 WaitForMultipleObjects and WaitForMultipleObjectsEx do
that, for up to 64 objects. In the Hammond Win32 extension
package, they're exported by win32event.

If 64 pipes in one call isn't enough, there are completion ports.
CreateIoCompletionPort is in win32file.

A third way in Win32 is WriteFileEx and a completion routine,
but it looks like the extension module doesn't support it.

I have not used the functions from the Hammond package, and
I notice the doc strings are None. You can probably figure
the wrappers out by reading the Microsoft documentation and
trying stuff. And of then there's the source.

If you put together a simple working example, I hope you'll
post it.


-- 
--Bryan



More information about the Python-list mailing list