Is there a portable way to tell if data is available on a pipe?

J

John Nagle

I need some way to find out if a pipe has data available for
a read without blocking if it does not.

"select", unfortunately, doesn't work on pipes on Windows.

I think there's something proposed for Python 3000, but that's
not useful now.

I'd like to avoid having a thread to manage each pipe, but if I
have to, so be it.

John Nagle
 
S

Scott David Daniels

John said:
I need some way to find out if a pipe has data available for
a read without blocking if it does not. ....
I'd like to avoid having a thread to manage each pipe, but if I
have to, so be it.

Well, without granting your wish, put a Queue.Queue "in front" of
each pipe. The per-pipe thread reads a chunk, waiting if it has to,
and then writes to the queue. To read from a pipe w/o waiting from
one of these assemblies, you can use the get_nowait method on the
associated queue.

--Scott David Daniels
(e-mail address removed)
 
J

John Nagle

Scott said:
Well, without granting your wish, put a Queue.Queue "in front" of
each pipe. The per-pipe thread ...

That's what I thought. Oh, well.

John Nagle
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top