473,785 Members | 2,466 Online
Bytes | Software Development & Data Engineering Community
+ 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=",lin e
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 1813
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.flu sh()" 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=",lin e
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.flus h 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.flu sh()" 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=",lin e
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
2909
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 late July. A number of obscure crash-causing bugs have been fixed, various memory leaks have been squished, but no new features have been added to the language or to the library. For more information on Python 2.3.1, including download links for...
3
7656
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 the socket for the connection. After I started the server, I can see one running process under Linux, which is ok. But once I connected to the Server, I always see two processes where one is the parent of the other. I think this should be
0
2491
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 running less than 5 threads. With more than 5, I get errors, but only on AIX, not on Linux. The python script is fairly simple, because each thread just spawns a korn
0
1373
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 a separate thread. Here's a little snippet of sample code that fails for me: ---- import thread, threading, wmi def wmiTest(c, callee):
10
9888
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 example: os.system("someapplication.exe") and kill it, if it waits longer than let's say 100 seconds
51
54877
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() # This thread is expected to finish within a second
9
1864
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 CPU-intensive work in another thread, but of course this won't work because of Python's GIL. There's a lot of past discussion on this, and I want to bring it up again because with the work on Python 3000, I think it is worth trying
3
3107
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 that must be running continuously during the five second interval. Thus, threading.Timer seems like a good function. Here is the relevant code: # background processes t = threading.Timer(5.0, function_name, )
1
1431
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 running thread and if its memory exceeds a certain amount than kill it. Ideally I would like the program to track memory used not just by that thread, but by any threads or processes that it may spawn. If there isn't anything like that, then...
6
1909
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 like a kludge having to spawn whole new processes build in socket communications and kill via explicit OS calls. I can't see that approach scaling particularly well but I guess there's no choice. Does anyone think it likely that the threading...
0
9647
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10356
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10098
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9958
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8986
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7506
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6743
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4058
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 we have to send another system
2
3662
muto222
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.