[IPython-user] Threading

Ville M. Vainio vivainio@gmail....
Wed Aug 20 10:46:09 CDT 2008

On Fri, Aug 15, 2008 at 11:37 PM, Gael Varoquaux
<gael.varoquaux@normalesup.org> wrote:

> # Make sure that we are using the right matplotlib backend. Elsewhere we
> # would crash even non-multithreaded GUIs
> from matplotlib import use
> use('WxAgg')
> from pylab import *
> t = arange(10)
> plot(t, sin(t))
> show()
> Run the thing a few times and a multithreaded frontend will crash. There is
> a hidden race-condition, so it might not crash the first time.

The race condition can't really be in ipython - the only thread that
actually runs the python code is the wx main thread.

However, I think the need to use threads in the first place is mostly
superstition. We could get by without threads easily:


The "secret sauce" is PyOS_InputHook, which runs the GUI event loops
while ipython is doing its raw_input.

Ville M. Vainio - vivainio.googlepages.com
blog=360.yahoo.com/villevainio - g[mail | talk]='vivainio'

More information about the IPython-user mailing list