Skip to content

Commit

Permalink
Handle throttling in notebooks
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr committed May 23, 2021
1 parent d52c2d5 commit 193f896
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 2 additions & 3 deletions holoviews/plotting/bokeh/callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,8 +290,7 @@ def _schedule_callback(self, cb, timeout=None, offset=True):
diff = time.time()-self._last_event
timeout = max(timeout-(diff*1000), 50)
if not pn.state.curdoc:
from tornado.ioloop import IOLoop
IOLoop.current().call_later(int(timeout)/1000., cb)
cb()
else:
pn.state.curdoc.add_timeout_callback(cb, int(timeout))

Expand Down Expand Up @@ -355,7 +354,7 @@ def process_on_event(self):
self._set_busy(False)
return
throttled = self.throttled()
if throttled:
if throttled and pn.state.curdoc:
self._schedule_callback(self.process_on_event, throttled)
return
# Get unique event types in the queue
Expand Down
4 changes: 3 additions & 1 deletion holoviews/plotting/bokeh/element.py
Original file line number Diff line number Diff line change
Expand Up @@ -816,6 +816,7 @@ def _update_ranges(self, element, ranges):
xaxis, yaxis = self.handles['xaxis'], self.handles['yaxis']
categorical = isinstance(xaxis, CategoricalAxis) or isinstance(yaxis, CategoricalAxis)
datetime = isinstance(xaxis, DatetimeAxis) or isinstance(yaxis, CategoricalAxis)
range_streams = [s for s in self.streams if isinstance(s, RangeXY)]

if data_aspect and (categorical or datetime):
ax_type = 'categorical' if categorical else 'datetime axes'
Expand All @@ -838,7 +839,6 @@ def _update_ranges(self, element, ranges):
else:
frame_aspect = plot.frame_height/plot.frame_width

range_streams = [s for s in self.streams if isinstance(s, RangeXY)]
if self.drawn:
current_l, current_r = plot.x_range.start, plot.x_range.end
current_b, current_t = plot.y_range.start, plot.y_range.end
Expand Down Expand Up @@ -907,6 +907,8 @@ def _update_ranges(self, element, ranges):
box_zoom.match_aspect = True
if scroll_zoom:
scroll_zoom.zoom_on_axis = False
elif any(rs._triggering for rs in range_streams):
xupdate, yupdate = False, False

if not self.drawn or xupdate:
self._update_range(x_range, l, r, xfactors, self.invert_xaxis,
Expand Down

0 comments on commit 193f896

Please sign in to comment.