[pygtk] Problem with pygtk, threads, an interactive interpreter and os.system()

Antoon Pardon Antoon.Pardon at rece.vub.ac.be
Wed Aug 18 21:32:13 WST 2004

On Tue, Aug 17, 2004 at 11:06:34AM -0600, Fernando Perez wrote:
> Hi all,
> I'm new to this list, but some of you in the python community may know me 
> from ipython (http://ipython.scipy.org).  I'm trying to add gtk support to 
> ipython, so that any gtk-based code can be executed and played with from an 
> interactive shell.  Based on:
> http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65109
> I've written the attached mini-interpreter pyint-gtk.py, which runs without 
> needing ipython to ease independent testing.  One of my main goals with 
> this effort is to support the gtk and wx backends for matplotlib, but this 
> should be useful to other users of pygtk as well.
> The attached code works fairly well for most purposes, but I'm having 
> problems with certain calls made by os.system(), specifically to gv (under 
> Linux, Fedora Core 2 at the moment).  If I call os.system('gv foo.eps &'), 
> gv seems to open fine, but after about 30 seconds of fiddling with it, 
> especially if I open zoom sub-windows, the gv GUI just hangs.  The process 
> becomes completely unresponsive, and the only way to kill it (and the gs 
> children it spawns) is via a manual kill -9.  The weird thing is that I've 
> tried opening other programs, including ggv on the same eps file (and 
> xcalc, konqueror, etc), and nothing else seems to show this behavior.

That is my experience too and I made sure that some of the programs
I called were gtk and pygtk programs, so my guess would be that it
is a gv problem.

> But I'm very leery of releasing this code as production stuff (the version 
> in ipython is different, since it integrates with the whole system, but the 
> threading code is identical and shows the same problem).  I don't know for 
> a fact that gv is the only culprit, and since I don't understand the root 
> cause of the problem, I'm afraid of having ipython randomly lock up on 
> people for no apparent reason.
> I am a complete ignoramus on threading issues, and this code was blindly 
> copied from the above recipe, so I may well be just doing something very 
> stupid.  I would be very appreciative of any help on this.

Well personnaly I would have never done it this way.

I think using a Queue would have been far simpler.

Antoon Pardon

More information about the pygtk mailing list