Try using readline() in a loop and see if that gives you better results.
I don't guarantee it will, but at least you will have some chance if
subprocess.open() *isn't* buffering the whole stream.
regards
Steve
--
I'm no expert.
"ex" == "has-been"; "spurt" == "drip under pressure"
"expert" == "has-been drip under pressure".
On 8/5/2010 7:16 PM, Joshua Russo wrote:Well, readlines() inherently has to see the end of the data stream
> On Aug 4, 6:49 pm, Hassan <hsn.zam...@gmail.com> wrote:
>>> Ok, so it appears that (in Python 2.5 at least) there is no way to capture
>>> the stdout of subprocess.Popen()
>>
>> just do this
>>
>> from subprocess import Popen, PIPE
>> p = Popen([cmd], stdout=PIPE)
>> p.stdout.readlines()
>>
>> thats it!
>
> The problem is that it waits for the process to end to output
> anything. Unless I was doing something wrong, but I think I was doing
> just what you describe here.
>
before it can return a list of all the lines that the data stream
contains, so that's hardly surprising is it?
Try using readline() in a loop and see if that gives you better results.
I don't guarantee it will, but at least you will have some chance if
subprocess.open() *isn't* buffering the whole stream.
regards
Steve
"Joshua Russo" <josh.r...@gmail.com> wrote:
>--
>You received this message because you are subscribed to the Google Groups "Django users" group.
>To post to this group, send email to django...@googlegroups.com.
>To unsubscribe from this group, send email to django-users...@googlegroups.com.
>For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
>
If I understand your issue correctly, in ran into something similar a while back. The problem is not in subprocess, but in how stdout works. The output is buffered by default, so it only gets written on a line-by-line basis.
If you want to catch it one character at a time, you have to explicitly flush the output after each character using sys.stdout.flush(). Then, of course, you'll also have to read it from subprocess one character at a time, too,
using .read(1) instead of .readline()
I hope that addresses your issue.
Cheers,
Cliff
--
Sent from my Android phone with K-9 Mail. Please excuse my brevity.
>
>
> Nope, still no dice. Below is what I did. I modified the worker()
> function from one of the Stackoverflow examples. Let me know if I'm
> using flush properly. Keep in mind that everything you see here is
> already running in a separate thread from the wxPython GUI so I can
> update the GUI while all my tests run in the background.
>
Sorry. I didn't realize you're doing this in a threaded/wxPython
context. I really don't have any experience with that kind of
programming. I was confused, because you posted to a django mailing
list. You might want to try another list that deals with wxPython
directly.
Cheers,
Cliff