Skip to content

Commit

Permalink
Set Panel state to busy during callbacks (#4546)
Browse files Browse the repository at this point in the history
* Set Panel state to busy during callbacks

* Fix for old panel versions
  • Loading branch information
philippjfr authored Aug 9, 2020
1 parent fbb4bca commit b5b9b05
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions holoviews/plotting/bokeh/callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,17 @@ def skip_event(self, event):
def skip_change(self, msg):
return any(skip(msg) for skip in self.skip_changes)

def _set_busy(self, busy):
"""
Sets panel.state to busy if available.
"""
if 'busy' not in state.param:
return # Check if busy state is supported

from panel.util import edit_readonly
with edit_readonly(state):
state.busy = busy

def _schedule_callback(self, cb, timeout=None, offset=True):
if timeout is None:
if self._history and self.throttling_scheme == 'adaptive':
Expand All @@ -393,6 +404,7 @@ def on_change(self, attr, old, new):
self._queue.append((attr, old, new, time.time()))
if not self._active and self.plot.document:
self._active = True
self._set_busy(True)
self._schedule_callback(self.process_on_change, offset=False)

def on_event(self, event):
Expand All @@ -403,6 +415,7 @@ def on_event(self, event):
self._queue.append((event, time.time()))
if not self._active and self.plot.document:
self._active = True
self._set_busy(True)
self._schedule_callback(self.process_on_event, offset=False)

def throttled(self):
Expand All @@ -429,6 +442,7 @@ def process_on_event(self):
"""
if not self._queue:
self._active = False
self._set_busy(False)
return
throttled = self.throttled()
if throttled:
Expand Down Expand Up @@ -457,6 +471,7 @@ def process_on_event(self):
def process_on_change(self):
if not self._queue:
self._active = False
self._set_busy(False)
return
throttled = self.throttled()
if throttled:
Expand Down

0 comments on commit b5b9b05

Please sign in to comment.