Skip to content

Remove the msg_throttle attribute (hardcode the throttle at 1). #1557

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

Merged
merged 3 commits into from
Aug 1, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/source/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 0 additions & 2 deletions ipywidgets/widgets/widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
5 changes: 2 additions & 3 deletions packages/base/src/widget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ class WidgetModel extends Backbone.Model {
_view_name: null,
_view_module_version: JUPYTER_WIDGETS_VERSION,
_view_count: null,
msg_throttle: 1,
};
}

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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.
Expand Down
1 change: 0 additions & 1 deletion packages/base/test/src/manager_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
Expand Down
33 changes: 0 additions & 33 deletions packages/base/test/src/widget_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
});
});
Expand Down Expand Up @@ -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);
Expand Down
3 changes: 1 addition & 2 deletions packages/schema/messages.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down