By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,199 Members | 1,077 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,199 IT Pros & Developers. It's quick & easy.

win32: emulating select() on pipes

P: n/a
hi

i'm trying to figure out if a pipe on win32 has data for me to read.
this is the code i've come up with:

def poll(self, timeout, interval = 0.2):
"""a poor man's version of select() on win32"""
from win32pipe import PeekNamedPipe
from msvcrt import get_osfhandle

handle = get_osfhandle(self.fileno())
if timeout is None:
timeout = sys.maxint
length = 0
tmax = time.time() + timeout
while length == 0 and time.time() < tmax:
length = PeekNamedPipe(handle, 0)[2]
time.sleep(interval)
return length != 0

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,
and returns True if there's something for me to read, or False
otherwise.
-tomer
Mar 17 '08 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.