[IPython-user] Workspaces with Embedded IPython

Gael Varoquaux gael.varoquaux@normalesup....
Fri Aug 15 15:37:17 CDT 2008


On Fri, Aug 15, 2008 at 10:20:09PM +0200, Laurent Dufréchou wrote:
>    If you take a look to my code, the threading stuff is only used when I do
>    make execute a command line to ipython instance. This is mainly to support
>    ctrl+c while you've launched a command. So in your case, you can easily
>    avoid the usage of mutexes etc...

The issue with the threading is that the users code should be
thread-safe. So if you go for multithreading the users have to enter only
thread-safe code. This is not realistic, IHMO. One example to crash a
multithreaded GUI python interpreter is simply to enter this:

# 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.

I have thought about this quite a lot, and decided not to go
multithreaded. Instead I try to be clever with the event loop to keep
interactive refresh, and maybe one day enable Ctrl-C (it doesn't seem
impossible).

We have discussed on the developpers mailing list these design decisions
a couple of months ago. Both choices are possible, but it really boils
down to what functionality you want to offer to the user.

Gaël


More information about the IPython-user mailing list