From 34a30382ec440c5b34ce68a3e31b76391776cf0b Mon Sep 17 00:00:00 2001 From: Jason Grout Date: Mon, 31 Jul 2017 17:30:07 -0400 Subject: [PATCH 1/3] Remove the msg_throttle attribute (hardcode the throttle at 1). --- ipywidgets/widgets/widget.py | 2 -- packages/base/src/widget.ts | 5 ++--- packages/schema/messages.md | 3 +-- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/ipywidgets/widgets/widget.py b/ipywidgets/widgets/widget.py index 4baaeb58a0..fe1e418f24 100644 --- a/ipywidgets/widgets/widget.py +++ b/ipywidgets/widgets/widget.py @@ -348,8 +348,6 @@ def get_view_spec(self): help="EXPERIMENTAL: The number of views of the model displayed in the frontend. This attribute is experimental and may change or be removed in the future. None signifies that views will not be tracked. Set this to 0 to start tracking view creation/deletion.").tag(sync=True) comm = Instance('ipykernel.comm.Comm', allow_none=True) - msg_throttle = Int(1, help="""Maximum number of sync msgs the front-end can send before receiving an idle msg from the back-end.""").tag(sync=True) - keys = List(help="The traits which are synced.") @default('keys') diff --git a/packages/base/src/widget.ts b/packages/base/src/widget.ts index fd1c5695e3..170da3d495 100644 --- a/packages/base/src/widget.ts +++ b/packages/base/src/widget.ts @@ -63,7 +63,6 @@ class WidgetModel extends Backbone.Model { _view_name: null, _view_module_version: JUPYTER_WIDGETS_VERSION, _view_count: null, - msg_throttle: 1, }; } @@ -254,7 +253,7 @@ class WidgetModel extends Backbone.Model { this._pending_msgs--; // Send buffer if one is waiting and we are below the throttle. if (this._msg_buffer !== null - && this._pending_msgs < (this.get('msg_throttle') || 1) ) { + && this._pending_msgs < 1 ) { this.send_sync_message(this._msg_buffer, this._msg_buffer_callbacks); this._msg_buffer = null; this._msg_buffer_callbacks = null; @@ -359,7 +358,7 @@ class WidgetModel extends Backbone.Model { let callbacks = options.callbacks || this.callbacks(); // Check throttle. - if (this._pending_msgs >= (this.get('msg_throttle') || 1)) { + if (this._pending_msgs >= 1) { // The throttle has been exceeded, buffer the current msg so // it can be sent once the kernel has finished processing // some of the existing messages. diff --git a/packages/schema/messages.md b/packages/schema/messages.md index 2bb5388d2a..ef99ecd42a 100644 --- a/packages/schema/messages.md +++ b/packages/schema/messages.md @@ -241,9 +241,8 @@ The core idea of widgets is that some state is automatically synced back and for * `_view_module`: the view module * `_view_module_version`: the semver range of the view * `_view_name`: the name of the view -* `msg_throttle`: an integer - the number of messages allowed 'in flight' for throttling purposes -The `_model_*` and `_view_*` fields are assumed immutable (set at initialization, and never changed). The `msg_throttle` field can be changed. +The `_model_*` and `_view_*` fields are assumed immutable (set at initialization, and never changed). ## Implementating the Jupyter widgets protocol in the kernel From 589a5183aca5d63dd5f5c19fd08fc81e37608cf9 Mon Sep 17 00:00:00 2001 From: Jason Grout Date: Mon, 31 Jul 2017 21:26:44 -0400 Subject: [PATCH 2/3] Fix tests --- packages/base/test/src/manager_test.ts | 1 - packages/base/test/src/widget_test.ts | 33 -------------------------- 2 files changed, 34 deletions(-) diff --git a/packages/base/test/src/manager_test.ts b/packages/base/test/src/manager_test.ts index d272709401..44bdb4edcd 100644 --- a/packages/base/test/src/manager_test.ts +++ b/packages/base/test/src/manager_test.ts @@ -434,7 +434,6 @@ describe("ManagerBase", function() { "_view_name":"TestWidgetView", "_view_module_version":"1.0.0", "_view_count":null, - "msg_throttle":1 }}}}; expect(state).to.deep.equal(expectedState); }); diff --git a/packages/base/test/src/widget_test.ts b/packages/base/test/src/widget_test.ts index 9ddfebb421..c84c8ecac4 100644 --- a/packages/base/test/src/widget_test.ts +++ b/packages/base/test/src/widget_test.ts @@ -559,7 +559,6 @@ describe("WidgetModel", function() { _view_name: null, _view_module_version: '3.0.0', _view_count: null, - msg_throttle: 1, a: 'get_state test' }); }); @@ -614,38 +613,6 @@ describe("WidgetModel", function() { b: 'change b again' }); }); - it('works with message throttle 2', function() { - let send = sinon.spy(this.widget, 'send_sync_message'); - this.widget.set('msg_throttle', 2); - this.widget.set('a', 'sync test'); - this.widget.save_changes(); - this.widget.set('a', 'another sync test'); - this.widget.set('b', 'change b'); - this.widget.save_changes(); - this.widget.set('b', 'change b again'); - this.widget.save_changes(); - - // check that one sync message went through - expect(send).to.be.calledTwice; - expect(send.firstCall).to.be.calledWith({ - a: 'sync test', - msg_throttle: 2 - }) - expect(send.secondCall).to.be.calledWith({ - a: 'another sync test', - b: 'change b' - }) - // have the comm send a status idle message - this.widget._handle_status({ - content: { - execution_state: 'idle' - } - }); - // check that the other sync message went through with the updated values - expect(send.thirdCall).to.be.calledWith({ - b: 'change b again' - }); - }); it('Initial values are *not* sent on creation', function() { expect(this.comm.send.callCount).to.equal(0); From d6249e666a00828f79197eb347dbb5abe20f657a Mon Sep 17 00:00:00 2001 From: Jason Grout Date: Mon, 31 Jul 2017 21:57:32 -0400 Subject: [PATCH 3/3] Add a changelog note about the msg throttle. --- docs/source/changelog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/source/changelog.md b/docs/source/changelog.md index 2882a1190e..d78c993c1d 100644 --- a/docs/source/changelog.md +++ b/docs/source/changelog.md @@ -36,6 +36,7 @@ Major user-visible changes in ipywidgets 7.0 include: - The `IntText`, `BoundedIntText`, `FloatText`, and `BoundedFloatText` widgets are now rendered as HTML number inputs, and have a `step` attribute that controls the resolution. ([#1545](https://github.com/jupyter-widgets/ipywidgets/pull/1545)) - The `Text.on_submit` callback is deprecated; instead, set `continuous_update` to `False` and observe the `value` attribute: `mywidget.observe(callback, 'value')`. The `Textarea.scroll_to_bottom` method was removed. ([#1545](https://github.com/jupyter-widgets/ipywidgets/pull/1545)) - The `readout_format` attribute of number sliders now validates its argument. ([#1550](https://github.com/jupyter-widgets/ipywidgets/pull/1550)) +- The `msg_throttle` attribute on widgets is now gone, and the code has a hardcoded message throttle equivalent to `msg_throttle=1`. ([#1557](https://github.com/jupyter-widgets/ipywidgets/pull/1557)) Major changes developers should be aware of include: