From 8869a32ea0af4e33fe9cc6e00b0fa93629070439 Mon Sep 17 00:00:00 2001 From: Philipp Rudiger Date: Mon, 31 Oct 2016 23:12:06 +0000 Subject: [PATCH 1/2] Add short timeout to callbacks --- holoviews/plotting/bokeh/callbacks.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/holoviews/plotting/bokeh/callbacks.py b/holoviews/plotting/bokeh/callbacks.py index 9b625eef25..6a07903ef3 100644 --- a/holoviews/plotting/bokeh/callbacks.py +++ b/holoviews/plotting/bokeh/callbacks.py @@ -115,14 +115,22 @@ class Callback(object): HoloViewsWidget.comm_state["{comms_target}"] = comm_state }} + function trigger() {{ + if (comm_state.event != undefined) {{ + comm.send(comm_state.event); + }} + comm_state.event = undefined; + }} + timeout = comm_state.timeout + {timeout}; if ((window.Jupyter == undefined) | (Jupyter.notebook.kernel == undefined)) {{ }} else if ((comm_state.blocked && (Date.now() < timeout))) {{ comm_state.event = argstring; }} else {{ - comm.send(argstring); + comm_state.event = argstring; + setTimeout(trigger, 20); comm_state.blocked = true; - comm_state.timeout = Date.now(); + comm_state.timeout = Date.now()+20; }} """ From 3e6b2ece01fb0691405f45842fbf64eebcf8e641 Mon Sep 17 00:00:00 2001 From: Philipp Rudiger Date: Mon, 31 Oct 2016 23:33:04 +0000 Subject: [PATCH 2/2] Exposed debounce callback parameter in python --- holoviews/plotting/bokeh/callbacks.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/holoviews/plotting/bokeh/callbacks.py b/holoviews/plotting/bokeh/callbacks.py index 6a07903ef3..335f8d1c97 100644 --- a/holoviews/plotting/bokeh/callbacks.py +++ b/holoviews/plotting/bokeh/callbacks.py @@ -128,9 +128,9 @@ class Callback(object): comm_state.event = argstring; }} else {{ comm_state.event = argstring; - setTimeout(trigger, 20); + setTimeout(trigger, {debounce}); comm_state.blocked = true; - comm_state.timeout = Date.now()+20; + comm_state.timeout = Date.now()+{debounce}; }} """ @@ -142,6 +142,9 @@ class Callback(object): # Timeout if a comm message is swallowed timeout = 20000 + # Timeout before the first event is processed + debounce = 20 + _callbacks = {} def __init__(self, plot, streams, source, **params): @@ -190,7 +193,8 @@ def set_customjs(self, handle): # Generate callback JS code to get all the requested data self_callback = self.js_callback.format(comms_target=self.comm.target, - timeout=self.timeout) + timeout=self.timeout, + debounce=self.debounce) attributes = attributes_js(self.attributes) code = 'var data = {};\n' + attributes + self.code + self_callback