##// END OF EJS Templates
Added msg_throttle sync=True widget traitlet
Jonathan Frederic -
Show More
@@ -34,7 +34,6 b' function(WidgetManager, _, Backbone){'
34 this.widget_manager = widget_manager;
34 this.widget_manager = widget_manager;
35 this._buffered_state_diff = {};
35 this._buffered_state_diff = {};
36 this.pending_msgs = 0;
36 this.pending_msgs = 0;
37 this.msg_throttle = 3;
38 this.msg_buffer = null;
37 this.msg_buffer = null;
39 this.key_value_lock = null;
38 this.key_value_lock = null;
40 this.id = model_id;
39 this.id = model_id;
@@ -110,7 +109,7 b' function(WidgetManager, _, Backbone){'
110 // Send buffer if this message caused another message to be
109 // Send buffer if this message caused another message to be
111 // throttled.
110 // throttled.
112 if (this.msg_buffer !== null &&
111 if (this.msg_buffer !== null &&
113 this.msg_throttle === this.pending_msgs) {
112 this.get('msg_throttle') || 3 === this.pending_msgs) {
114 var data = {method: 'backbone', sync_method: 'update', sync_data: this.msg_buffer};
113 var data = {method: 'backbone', sync_method: 'update', sync_data: this.msg_buffer};
115 this.comm.send(data, callbacks);
114 this.comm.send(data, callbacks);
116 this.msg_buffer = null;
115 this.msg_buffer = null;
@@ -179,7 +178,7 b' function(WidgetManager, _, Backbone){'
179 var callbacks = options.callbacks || this.callbacks();
178 var callbacks = options.callbacks || this.callbacks();
180
179
181 // Check throttle.
180 // Check throttle.
182 if (this.pending_msgs >= this.msg_throttle) {
181 if (this.pending_msgs >= this.get('msg_throttle') || 3) {
183 // The throttle has been exceeded, buffer the current msg so
182 // The throttle has been exceeded, buffer the current msg so
184 // it can be sent once the kernel has finished processing
183 // it can be sent once the kernel has finished processing
185 // some of the existing messages.
184 // some of the existing messages.
@@ -17,7 +17,7 b' from contextlib import contextmanager'
17 from IPython.core.getipython import get_ipython
17 from IPython.core.getipython import get_ipython
18 from IPython.kernel.comm import Comm
18 from IPython.kernel.comm import Comm
19 from IPython.config import LoggingConfigurable
19 from IPython.config import LoggingConfigurable
20 from IPython.utils.traitlets import Unicode, Dict, Instance, Bool, List, Tuple
20 from IPython.utils.traitlets import Unicode, Dict, Instance, Bool, List, Tuple, Int
21 from IPython.utils.py3compat import string_types
21 from IPython.utils.py3compat import string_types
22
22
23 #-----------------------------------------------------------------------------
23 #-----------------------------------------------------------------------------
@@ -103,6 +103,8 b' class Widget(LoggingConfigurable):'
103 _comm = Instance('IPython.kernel.comm.Comm')
103 _comm = Instance('IPython.kernel.comm.Comm')
104
104
105 closed = Bool(False)
105 closed = Bool(False)
106 msg_throttle = Int(3, sync=True, help="""Maximum number of msgs the
107 front-end can send before receiving an idle msg from the back-end.""")
106
108
107 keys = List()
109 keys = List()
108 def _keys_default(self):
110 def _keys_default(self):
General Comments 0
You need to be logged in to leave comments. Login now