Skip to content

fix: _pending_msgs was negative, iopub.status was called too often #3470

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

Conversation

maartenbreddels
Copy link
Member

This broke message throttling.

Fixes #3469

I think this should be backported to 7.x, since behaviour now is really badly defined. For views the throttling works the first time only (because the iopub callbacks gets reused when using .touch), for models (calling save_changes), we should not see this issue.

@github-actions
Copy link

Binder 👈 Launch a binder notebook on branch maartenbreddels/ipywidgets/fix_message_throttle_negative

@maartenbreddels maartenbreddels force-pushed the fix_message_throttle_negative branch from d3fe0a4 to 97025e2 Compare May 25, 2022 16:19
@maartenbreddels
Copy link
Member Author

As I suggested in #3469 the following works much better:

import time
import ipywidgets as w

@w.interact
def test(f = 10.1):
    print(f**2)
    time.sleep(1)

Before this would take many seconds to finish (there is a long queue of messages that will trigger the test function), while with this PR it is only max 2 seconds (the one in flight, and the 1 pending).

Also, websocket messages behave as predicted/expected now:
image

1 update to the kernel, followed by busy/echo/idle (for 7.x that should just be busy/idle).

@jasongrout jasongrout added this to the 8.0 milestone May 31, 2022
@ibdafna ibdafna merged commit fbdc7f8 into jupyter-widgets:master Jun 3, 2022
@jasongrout
Copy link
Member

@meeseeksdev please backport to 7.x

@lumberbot-app
Copy link

lumberbot-app bot commented Jun 9, 2022

Owee, I'm MrMeeseeks, Look at me.

There seem to be a conflict, please backport manually. Here are approximate instructions:

  1. Checkout backport branch and update it.
git checkout 7.x
git pull
  1. Cherry pick the first parent branch of the this PR on top of the older branch:
git cherry-pick -x -m1 fbdc7f8fdd4f7d2bb9eb759917971f311991d27c
  1. You will likely have some merge/cherry-pick conflict here, fix them and commit:
git commit -am 'Backport PR #3470: fix: _pending_msgs was negative, iopub.status was called too often'
  1. Push to a named branch:
git push YOURFORK 7.x:auto-backport-of-pr-3470-on-7.x
  1. Create a PR against branch 7.x, I would have named this PR:

"Backport PR #3470 on branch 7.x (fix: _pending_msgs was negative, iopub.status was called too often)"

And apply the correct labels and milestones.

Congratulations — you did some good work! Hopefully your backport PR will be tested by the continuous integration and merged soon!

Remember to remove the Still Needs Manual Backport label once the PR gets merged.

If these instructions are inaccurate, feel free to suggest an improvement.

@jasongrout jasongrout mentioned this pull request Jun 10, 2022
jasongrout added a commit to jasongrout/ipywidgets that referenced this pull request Jun 10, 2022
jasongrout added a commit to jasongrout/ipywidgets that referenced this pull request Jun 10, 2022
This partially reverts changes from jupyter-widgets#3470.

I think the underlying assumptions around send_sync_message and callbacks are:

1. send_sync_message is only ever called once per message. When the original sync happens, either we put the message on the queue or we send it immediately, and the callback modifications happen only when we actually send the message.
2. There was an implicit assumption in the send_sync_message code is that the callbacks object passed in is a new object unique to this message, i.e., we aren't modifying a global object, that then we'll modify again later.

I think assumption 2 is sometimes not true, so this guards against it by making a (2-deep) copy of the callbacks object before modifying and using it.
jasongrout added a commit to jasongrout/ipywidgets that referenced this pull request Jun 11, 2022
This partially reverts changes from jupyter-widgets#3470.

I think the underlying assumptions around send_sync_message and callbacks are:

1. send_sync_message is only ever called once per message. When the original sync happens, either we put the message on the queue or we send it immediately, and the callback modifications happen only when we actually send the message.
2. There was an implicit assumption in the send_sync_message code is that the callbacks object passed in is a new object unique to this message, i.e., we aren't modifying a global object, that then we'll modify again later.

I think assumption 2 is sometimes not true, so this guards against it by making a (2-deep) copy of the callbacks object before modifying and using it.
jasongrout added a commit to jasongrout/ipywidgets that referenced this pull request Jun 22, 2022
…pub.status was called too often

This backports commit 97025e2 from master to the 7.x branch.
@jasongrout
Copy link
Member

Backported in #3494

jasongrout added a commit that referenced this pull request Jun 22, 2022
Backport PR #3470 and #3485: Fix message throttling
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: Message throttling is broken after first update message from frontend
3 participants