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

Fix message throttle by making a copy of the callbacks dict #3485

Merged
merged 2 commits into from
Jun 21, 2022

Conversation

jasongrout
Copy link
Member

Fixes #3469 in a different way from #3470.

This partially reverts code changes from #3470, but leaves the tests.

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 jasongrout added this to the 8.0 milestone Jun 10, 2022
@github-actions
Copy link

Binder 👈 Launch a binder notebook on branch jasongrout/ipywidgets/throttle

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.
@maartenbreddels
Copy link
Member

Hi Jason,

I tried a (lodash) clone, but that didn't work, this solution is much better.
LGTM!

cheers,

Maarten

@jasongrout jasongrout merged commit e6ba2b6 into jupyter-widgets:master Jun 21, 2022
@jasongrout
Copy link
Member Author

@meeseeksdev please backport to 7.x

@lumberbot-app
Copy link

lumberbot-app bot commented Jun 22, 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 e6ba2b68ae4e0f444efcab51361ed7c755f1c36b
  1. You will likely have some merge/cherry-pick conflict here, fix them and commit:
git commit -am 'Backport PR #3485: Fix message throttle by making a copy of the callbacks dict'
  1. Push to a named branch:
git push YOURFORK 7.x:auto-backport-of-pr-3485-on-7.x
  1. Create a PR against branch 7.x, I would have named this PR:

"Backport PR #3485 on branch 7.x (Fix message throttle by making a copy of the callbacks dict)"

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 added a commit to jasongrout/ipywidgets that referenced this pull request Jun 22, 2022
…py of the callbacks dict

This backports d8e7fb6 and 353316a from master to 7.x.
jasongrout added a commit to jasongrout/ipywidgets that referenced this pull request Jun 22, 2022
…py of the callbacks dict

This backports d8e7fb6 and 353316a from master to 7.x.
@jasongrout
Copy link
Member Author

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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

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