Skip to content
This repository

Interrupting certain matplotlib operations leaves the inline backend 'wedged' #992

Closed
fperez opened this Issue · 5 comments

2 participants

Fernando Perez Min RK
Fernando Perez
Owner

This is something I've only noticed on the notebook, though it likely also occurs with the qt console. If I interrupt a matplotlib rendering operation, quite often it becomes impossilbe to get any further plots to show up. Somewhere, we're holding state that isn't fully restored if the rendering operation is interrupted by the user.

Typing %pylab inline fixes it, but that's an arcane solution which also has the side-effect of re-importing all the pylab namespace on top of the user's interactive namespace.

I've had this bite me often enough lately to realize it will be a major usability headache for new users of the notebook, which is why I'm making it critical. I suspect it will be easy to fix once we have a look at our inline pylab code.

Min RK
Owner

It does indeed affect the qtconsole.

I presume this is my fault, from the changes in #892. I'll dig in.

Min RK
Owner

It turns out, this isn't in my changes at all, it's the fact that post-execute functions are unregistered on any exception (including KeyboardInterrupt). This is indeed easily fixed. There are two obvious options:

  1. never deactivate post-execute hooks on KeyboardInterrupt
  2. catch KeyboardInterrupt in flush_figures itself

I think 1. makes more sense, and is trivially fixed. I'll do a PR with this in a minute, adding some cleanup in the backend to make sure that the state is cleared, even if flush_figures() is interrupted.

Min RK
Owner

PR #997 issued.

Fernando Perez
Owner

Closed by f3fe1c1, auto-close seems to be completely broken these days on github.

Fernando Perez fperez closed this
Fernando Perez
Owner

oops, didn't click 'close'.

Stefan van der Walt stefanv referenced this issue from a commit in stefanv/ipython
Min RK don't unregister interrupted post-exec functions
only unregister on real Exceptions.

also put close/cleanup for the inline backend calls inside `finally` block,
to ensure that the state is clean on the next round, even if show/flush is interrupted

closes gh-992
f3fe1c1
Fernando Perez fperez referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.