Ipython: Importing pyplot causes bouncing dock icon on mac

Created on 8 Jan 2017  ·  10Comments  ·  Source: ipython/ipython

This is illustrated by the following gif:

image

Importing pyplot in the normal python repl causes the python rocket icon to appear but not bounce distractingly. Importing it inside IPython causes the icon to bounce annoyingly for almost a minute.

This is using a framework build of Python from Homebrew.

bug

Most helpful comment

It just took me 10 seconds to realize that my machine was not frozen but that the pointer I was looking at was the pointer in your .gif.

All 10 comments

which backend are you using? Does running plt.ion() or %matplotlib help?

My knee-jerk / making this up as I go guess is: When IPython de-coupled from readline, it also decoupled from the PyOS_InputHook machinery. In the plain python case, the GUI is starting up (starting the bouncing), the GUI code installs the hook, and when it finishes starting up some how phones home to let the rocket know to stop bouncing because the gui main loop runs intercolated with the repl. In IPython, that hook is still installed, but does not matter because IPython is running through prompt toolkit. If you start up the IPython event loop integration the GUI will phone home and stop the bouncing.

Or I could be wildly off base.

This is using the MacOSX backend. Using plt.ion() or %matplotlib after the pyplot import doesn't stop the bouncing and using %matplotlib before doing the pyplot import just causes the icon to start bouncing.

Does it happen with the tk backend?

Nope, no rocket icon at all with TkAgg.

I'm going to stay that's linked to #9312
I'm going to try to understand it. Ping @minrk.

I'm going to say that this:

    if not window_count:
        return

Need to be removed as the eventloop integration need to run even if there is no windows... it appears to be working for me.
Alternative would be to make sure inputhook(context) does at least one loop even if no windows.. so along:

    global at_least_once
    if not window_count and not at_least_once:
        at_least_once = True
        return

@ngoldbaum would you mind trying ?
Also I suppose it stop bouncing as soon as you have your first window ?

The screen recording also make me happy because it is realistic in its typing, and make me feel less guilty about my horrendous typing.

Indeed, removing that

if not window_count:
    return

block fixes the issue for me. And as you suspected, creating a plot stops the bouncing.

Submitted #10150, will wait for review of more qualified people.

It just took me 10 seconds to realize that my machine was not frozen but that the pointer I was looking at was the pointer in your .gif.

Was this page helpful?
0 / 5 - 0 ratings