[IPython-dev] Cython based PyOS_InputHook hack

Brian Granger ellisonbg.net@gmail....
Sun Feb 8 15:55:10 CST 2009


>> > Sorry, Brain, I don't know wx well-enough to do this without a
>            ^
>        Sorry, Brian, this was a typo.

That is funny.  My first driver's license had this typo - I first
noticed it when I got pulled over by a cop and had to expain that my
name was not "Brain".

>> > significant time investement (these things are tricky). I don't see myself
>
>> Inferring from your other mail, it would only seem necessary to call
>> the mainloops Yield in the input hook function.
>
> I believe this is very risky. Yield is a very fragile function. For
> instance, under Windows, calling a Yield inside a Yield is not possible.
> So if you have a GUI callback that calls a raw_input, you are likely to
> end up in this situation (recursive call of Yield) when plugging readline
> in the GUI as currently done with "ipython -wthread".

But, I think there are protections for this:

Calling the Yield method on the application object while in Yield is
a bug, i.e. Yield is not reentrant. The debug version of wxWidgets
throws an assert in this case (that bug is assigned to me). If you
need to call Yield and you're not absolutely sure you're not being
called from Yield, you should pass True to Yield, i.e. wx.GetApp
().Yield(True), which will return instead of recursing in this case.

> I am not saying this is not the way to go. I am saying it needs thinking
> and validation.

For sure, would $20 that a simple call to Yield won't work in all cases.

Cheers,

Brian

> Gaël
>


More information about the IPython-dev mailing list