From: Steve C. <ste...@ya...> - 2005-01-30 08:37:08
|
On Wed, 2005-01-26 at 22:18 +0100, Baptiste Carvello wrote: I've finally got round installing the interactive gui thread patch to have a look at it. It worked quite well for a few simple plots I tried. > A bug in the handling of threads_enter()/threads_leave() leads to a > deadlock, while a bug with a gui thread yields "Xlib async reply". > Choose which ugly death you prefer ! What situation would yield an "Xlib async reply"? > There are several strategies: ... > * wrap only pylab functions (draw_if_interactive etc), as you seem to > suggest in your second email: imho this is not acceptable because it > breaks method calls of matplotlib objects How does it break method calls of matplotlib objects? In interactive mode the gtk backend does not work (by itself) so there's nothing to break, and in non-interactive mode the gui_cmd() function would not be used. When thinking about using threads for interactive mode I had been assuming people using the interactive mode would be using the pylab interface, does anyone use the matplotlib class interface in interactive mode? I have a few questions about patch itself: In import_gtk() there is time.sleep(1) - what is that for? Shouldn't widget creation be protected as well by wrapping things like new_figure_manager() and FigureCanvasGTK(). I know __init__ is wrapped but objects may have __new__ methods which call gdk/gtk functions before __init__ is called. How about if a widgets standard methods such as show(), present() etc are used - they are not protected (unless called from a protected method). I think this just applies to using the class interface in interactive mode, so it may be rarely encountered but might be a problem. Why use gtk_protect(), exec() and GTK_TEMPLATE, when you could use: def gtk_protect (fun): def decorator (*args, **kwargs): if IN_GTK or threading.currentThread() is Thread: return fun(*args, **kwargs) IN_GTK.append (fun) gtk.threads_enter() try: res = fun(*args, **kwargs) finally: gtk.threads_leave() IN_GTK.pop() return res return decorator Steve |