Re: read and readline hanging

2008-01-28 Thread Olivier Lefevre
>> But in python eventually stdout.readline() hangs. This is a real >> nuisance: why can't it just return None? > > Because that would be quite annoying because most of the time people want > blocking behavior. Just an afterthought: do people prefer the blocking behaviour because blocking until

Re: read and readline hanging

2008-01-28 Thread Olivier Lefevre
pexpect looks promising, thanks. -- O.L. -- http://mail.python.org/mailman/listinfo/python-list

Re: read and readline hanging

2008-01-28 Thread Olivier Lefevre
>> Yes, that has since occurred to me. I need to echo some magic string >> after each command to know that I reached the end of the answer to >> the previous command. In interactive mode the prompt fulfills that >> role. > > And hope that that "magic string" does not occur somewhere within > the r

Re: read and readline hanging

2008-01-28 Thread Olivier Lefevre
> The buffering behavior at the interactive prompt is very often different > from connections via pipes. I hadn't thought of that. I will ask on the Octave list. Thanks, -- O.L. -- http://mail.python.org/mailman/listinfo/python-list

Re: read and readline hanging

2008-01-27 Thread Olivier Lefevre
>> Indeed, if I do this interactively, I can tell after 3 lines that I've >> gotten all there is to get right now and the fourth readline() call >> hangs. > > Can you really? Yes interactively: at the command prompt, you can tell when it's over because you know the command you just sent and whet

Re: read and readline hanging

2008-01-27 Thread Olivier Lefevre
> The `trheading` module is modeled after Java's threading API. OK. Thanks for the hint. However BufferedReader.readline() does not block in Java, so it is still difficult to transpose. >> But how can I find out *programmatically* that there is no more >> input? > > You can't. How do people han

Re: read and readline hanging

2008-01-25 Thread Olivier Lefevre
Hi Steve, Thanks for the answer. Yes this is tricky. I have done it in Java before, where you can, e.g., set up a thread to pump stuff out of both stderr and stdout continuously but my python is too rudimentary for that. There is a key difference anyway: in Java you can write while (br.readL

read and readline hanging

2008-01-24 Thread Olivier Lefevre
I am calling subprocess.Popen with p = Popen(args, bufsize=-1, stdin=PIPE, stdout=PIPE, stderr=PIPE) and after sending come command to the process, I try to read from p.stdout but after a few calls I hang. What is the correct way to do this, i.e., to read everything w/o getting stuck? I am not fami