>
> 1) You might add some print statements to see how often you're actually
> calling select() and read().  Unless you explicitly set your streams to
> unbuffered mode, read() without arguments should try to read until EOF
> (see pydoc file.read), which doesn't play well with select.  I'm not
> sure if this is actually your problem, but it's something to pay
> attention to.
>
> Yeah, I did try that.  Until some input is read in, it doesn't do anything
in this case.  As soon as it receives any inputs it then enters an infinite
loop and just ignores the select statement all together.

2) If select is really being called over and over, what is the value of
> data in the loop?  If it's the empty string, then the stream is trying
> to tell you that it's reached EOF and needs to be closed.  You should
> probably add:
>    if not data:
>        stream.close()
> just after the line with stream.read().
>
> I've tried closing the streams in various ways.  The problem is that this
needs to be persistent and periodically re-read the inputs.  I can't re-open
these streams after closing them.
I've also used readline at other points as opposed to read since in this
context I can neatly divide all the inputs of worth by newline characters.


> 3) You shouldn't need to flush streams that you're reading from.  That's
> an operation for writing.
>
Good to know


> 4) I noticed that the Popen sets a pipe for stdin but not actually
> writing to myProcess.stdin.  This wouldn't cause the exact symptom that
> you're seeing, but there are a few cases where deadlock can occur when
> reading and writing aren't both in the select loop.
>
> It uses stdin later in the program--this was just me abbreviating it into
the parts that are troubling me.


At this point, I'm rather convinced that I'm not going to be able to use
select at all since the myPrco.stderr stays in a readable state and sends
this into an infinite loop as soon as it gets data.  I'm trying to figure
out how to do this with some threads to handle each input stream
individually--but I really can't find any examples (after about an hour of
searching) of how to do this in python.

-- 
Todd Millecam
--------------------
BYU Unix Users Group 
http://uug.byu.edu/ 

The opinions expressed in this message are the responsibility of their
author.  They are not endorsed by BYU, the BYU CS Department or BYU-UUG. 
___________________________________________________________________
List Info (unsubscribe here): http://uug.byu.edu/mailman/listinfo/uug-list

Reply via email to