thread and processes with python/GTK

A

awalter1

Hello,

I'm developping an application with python, pyGTK and GTK+.
I've performed many tests by using methods as Popen, popen2,
os.system ... to communicate with Unix (HPUX),
The last attempt is this code written in a thread :
fin,fout = popen2.popen2('ps -def')
line = fin.readline()
while 1 :
if not line : break
print "line=",line
line = fin.readline()
fin.close()
In that case, lines are printed only when I exit my application.
Usually the behavior is not as expected and I cannot understand why. I
am wondering that it could be a constraint from the use of GTK
(mainloop() existence ???).
Is somebody aware about conflict between GTK use and unix mechanism.

Thanks for you help
 
T

Thomas Guettler

Hi,

how do you start the python app? Goes stdout
to a terminal or a pipe?

"python script.py"
and "python script.py | cat" behave different.

Maybe "sys.stdout.flush()" helps you.

BTW, I switched from threads to idle_add for pygtk
applications.
 
A

awalter1

HI,

I launch my application by 'python script.py'
I've already add a sys.stdout.flush with no effect.

if the idle_add is an alternative to thread, where to get details
about its use (no reference in http://www.pygtk.org/docs/pygtk/
index.html, but very brief information in GTK+ documentation)
In my case how to implement the system call 'ps -def' through idle_add

Thanks
 

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

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top