Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Double output on Ctrl-enter-enter #4223

Closed
takluyver opened this issue Sep 17, 2013 · 3 comments · Fixed by #4224
Closed

Double output on Ctrl-enter-enter #4223

takluyver opened this issue Sep 17, 2013 · 3 comments · Fixed by #4224
Milestone

Comments

@takluyver
Copy link
Member

(Reported by Fujun Du on the mailing list)

When I run a cell in place with "Control-Enter" to make a plot, and if I press the key combination very quickly twice (namely, press "Control-Enter-Enter"), I will have two copies of the same plot shown below the cell.

This is nothing important but just for you to know the issue. To reproduce the behavior, I guess the computation in the cell must take quite some time to finish (to be slower than the key press). For example, put the following code into a new cell and press "Control-Enter-Enter" quickly you will get two output "xxx". In case your computer is very fast, add one or a few more zeros to the xrange:

import math
for i in xrange(1000000):
    a = math.sin(i)
print 'xxx'
@jsw-fnal
Copy link

This is not unique to Control-Enter. It works with Shift-Enter and the various "Run" options from the cell menu as well. You don't even have to use the same means of execution twice, for example Control-Enter followed by "Run all" will produce doubled output.

Finally, you don't need a spinning delay (like a long computation) to produce this effect. Making a delay with time.sleep() works just as well.

import time
time.sleep(5)
print 'xxx'

@minrk
Copy link
Member

minrk commented Sep 17, 2013

This is a bit more general than an order of operations bug. This should be a summary of the relevant bits:

  • when you execute, cell.output_area.handle_output is registered as the callback
  • this callback is never cleared
  • when you submit a new execution, the output_area is cleared, but it remains the same object, so the old callback is still registered
  • if output from an execution has not come by the time the cell is resubmitted, the earlier executions output will still be appended

I think we can get away with fixing this by simply clearing the callbacks for the last execution when we submit a new one.

minrk added a commit to minrk/ipython that referenced this issue Sep 17, 2013
avoids mixed up display of multiple executions in one output area
when a cell is resubmitted.

closes ipython#4223
@minrk
Copy link
Member

minrk commented Sep 17, 2013

should be fixed by #4224.

mattvonrocketstein pushed a commit to mattvonrocketstein/ipython that referenced this issue Nov 3, 2014
avoids mixed up display of multiple executions in one output area
when a cell is resubmitted.

closes ipython#4223
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants