From: Fernando P. <Fer...@co...> - 2005-01-27 17:12:12
|
Steve Chaplin wrote: > On Tue, 2005-01-25 at 22:25 -0700, Fernando Perez wrote: > >>In case anyone is interested, here's a lightweight, standalone (non-ipython) >>GTK threaded interactive interpreter with matplotlib support. This code is >>also based on the same ASPN recipe, it's basically the prototype I used to >>understand that recipe when I was adding the matplotlib support to IPython. > > Thanks, its a good example of code.InteractiveConsole, when I saw codeop in > the ASPN recipe I wondered why code.py was not used. > > I noticed a few small points: > - GTKInterpreter says "Run a gtk mainloop() in a separate thread.", yet > gtk.main() runs in the main thread, and the interpreter/console runs in > a separate thread. > - gtk.timeout_add() is now deprecated in favour of gobject.timeout_add() > > - runsource() and runcode() are synchronised using wait()/notify() so > they deal with one code object at a time. If self.code_to_run is changed > to a code queue (using list.append() and list.pop(0)) then the wait > ()/notify() could be removed and the interpreter thread would return > immediately it adds the code to self.code_to_run and not when the main > thread has executed the code. I am _really_ ignorant of thread issues, and so I have avoided touching the threading part of this code at all, though I've always suspected it could be cleaner. Would you mind applying these fixes and sending it back my way (including the GTK stuff)? I could then port your improvements over to the code in ipython proper which implements this same functionality. Cheers, f |