ipython/ipython — Issue #1154: We should be less aggressive in de-registering post-execution functions
Author: fperez
Created: 2011-12-14 17:51:55+00:00
State: open
Labels: prio-blocker

I'm marking this as a blocker so we make a decision on it in the next few days. If we decide to make a change, the implementation is easy.

Currently, if a post-execution function fails we immediately de-register it. The rationale for this was originally that if the user had a bad function, there was no point in failing every time.

But in more extensive use, I'm realizing this is a bad policy in practice. To see the issue, try in a pylab notebook just this one cell:

```
plt.title("Naïve")
```
note that this is unicode *without* the proper `u` qualifier. That triggers a matplotlib exception (as it should) but we immediately go ahead and disable further figure display:

```
Disabling failed post-execution function:
ERROR: An unexpected error occurred while tokenizing input
The following traceback may be corrupted or invalid
The error message is: ('EOF in multi-line statement', (316, 0))
```

So even though in this case the user did pass invalid input, from this point on their experience will simply be "the notebook doesn't work anymore". They can recover functionality by calling `%pylab` which re-registers the figure display function, but most people will just be puzzled by the behavior and likely just do a full session restart (possibly losing costly computations).

I think what we should do instead is to store in a set all functions that have ever failed at this stage, and change the error message to something like:

```
Function <....> produced an error. If this problem persists, you can disable all problematic post-execution functions by calling:

get_ipython().disable_failing_postfuncs()
```

The user can then make the call manually if they really need it. But in a case like this example, they would simply realize their mpl error, fix their call and be able to continue.