473,480 Members | 2,300 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

thread and processes with python/GTK

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

Jan 30 '07 #1
2 1798
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.

awalter1 wrote:
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
--
Thomas Güttler, http://www.thomas-guettler.de/ http://www.tbz-pariv.de/
E-Mail: guettli (*) thomas-guettler + de
Spam Catcher: ni**************@thomas-guettler.de

Jan 30 '07 #2
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

On 30 jan, 16:44, Thomas Guettler <guettli.use...@thomas-guettler.de>
wrote:
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.

awalter1 wrote:
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

--
Thomas Güttler,http://www.thomas-guettler.de/http://www.tbz-pariv.de/
E-Mail: guettli (*) thomas-guettler + de
Spam Catcher: niemand.leerm...@thomas-guettler.de- Masquer le texte des messages précédents -

- Afficher le texte des messages précédents -

Jan 31 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

38
2834
by: Anthony Baxter | last post by:
On behalf of the Python development team and the Python community, I'm happy to announce the release of Python 2.3.1 (final). Python 2.3.1 is a pure bug fix release of Python 2.3, released in...
3
7629
by: Thomas Schmid | last post by:
Hi there, I wrote a tcp server which listens on a port. When he gets a new connection, he starts a new thread like this: thread.start_new_thread(self.ConnectionHandler, (conn,)) where conn is...
0
2464
by: Gardner Pomper | last post by:
Hi, I am pretty new to python, so be gentle :) I have a python script that spawns a number of threads (configurable) on a 12 processor AIX RISC-6000 machine. It works fine, so long as I am...
0
1346
by: Fazan | last post by:
I'm using Tim Golden's WMI implementation (http://tgolden.sc.sabren.com/python/wmi.html) version 0.6 along with pywin32 build 202. I'm able to successfully query WMI in the main thread but not in...
10
9846
by: Jacek Pop³awski | last post by:
Hello. I am going to write python script which will read python command from socket, run it and return some values back to socket. My problem is, that I need some timeout. I need to say for...
51
54757
by: Hans | last post by:
Hi all, Is there a way that the program that created and started a thread also stops it. (My usage is a time-out). E.g. thread = threading.Thread(target=Loop.testLoop) thread.start() ...
9
1830
by: cgwalters | last post by:
Hi, I've recently been working on an application which does quite a bit of searching through large data structures and string matching, and I was thinking that it would help to put some of this...
3
3095
by: Jonathan Shan | last post by:
Hello, I am trying to call a function every 5 seconds. My understanding of time.sleep() is during the sleep time everything "stops". However, in my application, there are background processes...
1
1411
by: JamesHoward | last post by:
Are there any good thread profilers available that can profile a thread as it is running instead of after execution is completed? I would like to find a python class which looks at a currently...
6
1891
by: Roger Heathcote | last post by:
sjdevnull@yahoo.com wrote: <snip> Fair point, but for sub processes that need to be in close contact with the original app, or very small functions that you'd like 100s or 1000s of it seems...
0
6911
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
6966
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5344
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4787
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4488
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
2999
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
2988
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1303
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
564
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.