[IPython-dev] Preventing "Oops, IPython crashed" ?

Fernando Perez Fernando.Perez at colorado.edu
Wed Dec 28 18:25:26 EST 2005


Hans Meine wrote:
> On Thursday 11 August 2005 21:49, Fernando Perez wrote:
> 
>>So I'm afraid I don't really know how to solve this particular problem
>>cleanly.  Any ideas would be most welcome.  Specifically, a way to trap the
>>mpl exceptions only would do the trick, but all try/excepts I've tried to
>>wrap around the mpl threads have so far failed.
> 
> 
> Yes, I understood the problem is hard-to-impossible to solve cleanly, but what 
> I wanted to say is that it'd make sense to document the workaround
> 
>  sys.excepthook = __IPYTHON__.excepthook
> 
> or even make it a configurable option.  The problem I have is not with 
> matplotlib, but with Qt:  If you write an interactive Qt program (which is 
> most probable if you're using Qt in the first place), your code will most 
> probably be executed from the GUI thread and as such all small mistakes in 
> your own code will result in this lengthy default exc.handler output.
> 
> I hard-coded the above statement into IPShellQt.__init__ since IPShellQt is 
> much less usable otherwise.  So I propose a documented ipythonrc switch that 
> activates this, possibly only for IPShellQt if other toolkits work 
> differently.
> 
> I hope this made my intention more clear. :-)

OK, I just committed this.  Straight from the changelog:

	(InteractiveShell.__init__): change threaded shells to not use the
	ipython crash handler.  This was causing more problems than not,
	as exceptions in the main thread (GUI code, typically) would
	always show up as a 'crash', when they really weren't.

	The colors and exception mode commands (%colors/%xmode) have been
	synchronized to also take this into account, so users can get
	verbose exceptions for their threaded code as well.  I also added
	support for activating pdb inside this exception handler as well,
	so now GUI authors can use IPython's enhanced pdb at runtime.


So now you get pdb, pretty tracebacks, color highlighting, and even the 
verbose tracebacks (%xmode verbose) in your GUI code.

Let me know how this works.

Best,

f




More information about the IPython-dev mailing list