[SciPy-dev] Generic gui_thread + IPython: solution already exists!

Fernando Perez Fernando.Perez at colorado.edu
Sun Nov 14 21:32:43 EST 2004


Prabhu Ramachandran wrote:

> The approach Fernando uses is identical to what is done in the
> gpython.py shell used to run pyGTK interactively.  A wxApp or
> gtk.mainloop() is run in a background thread and *everything* typed by
> the user is run in it.  IPython grabs whatever the user types and then
> sends this off to the second thread and executes it there.  Thus,
> things are always done in the right thread and there are no issues.
> The only problem is exceptions, signal handlers etc.  It looks like
> exceptions are trapped nicely and passed back to the main thread.  I
> don't know about the signal handlers.

Signal handling is a mess.  The thread you referred to originally mentions 
this.  My brute-force approach was to install a sigint handler _every_ time I 
enter the 2nd thread, right before executing user code.  Somehow this seems to 
allow me to trap SIGINT correctly, which I otherwise could never catch (and it 
would blow things up badly).

 From what others on c.l.py said, this is not an easy problem, but if anyone 
knows of a cleaner solution than what I came up with (an admittedly gross 
hack), I'm all ears.

Best,

f




More information about the SciPy-Dev mailing list