[IPython-user] Threading

Gael Varoquaux gael.varoquaux@normalesup....
Wed Aug 20 23:26:11 CDT 2008

On Wed, Aug 20, 2008 at 06:46:09PM +0300, Ville M. Vainio 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.

Right, but then if you ipython is in a wx frontend, the refresh of the
GUI is blocked when you run the code, thus you don't get IO.

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

> http://ipython0.wordpress.com/2008/05/15/embedding-ipython-in-gui-apps-is-trivial/

But you don't use a wx frontend. You use a terminal to host your ipython.
This is not what we are talking about.

This is a hard problem, and I advise anybody who is going to try and
tackle it to think twice before coming up with a "solution".


More information about the IPython-user mailing list