Value throttled not working when updating from 0.10 to 0.11

Hi all !!

I update panel from version 0.10 to 0.11 and the param.value_throttled option in the decorator does not work anymore. I try in two different computers and the next code prints nothing.

import panel as pn
print (pn.__version__)

sli = pn.widgets.FloatSlider(value= 5, start=0, end=10)

@pn.depends(sli.param.value_throttled, watch=True)
def test_throttled(v1):
    print (v1)

pn.Row(sli).servable()

I saw some PR where the throttled options was modified, but I can not understand how to use it now with the depends decorator.

thanks,
N.

I could recreate the problem. It seems to be because a change in Bokeh which raises a RuntimeError when changing the value_throttled parameter as it is ReadOnly.

This is hidden by _rename dict in the FloatSlider class. So if I change the FloatSlider._rename from _rename = {'name': 'title', 'value_throttled': None} to _rename = {'name': 'title'}. I get the following RuntimeError:

2021-03-14 08:23:18,178 Exception in callback functools.partial(<bound method IOLoop._discard_future_result of <tornado.platform.asyncio.AsyncIOMainLoop object at 0x000002CD3FB7EC48>>, <Task finished coro=<_needs_document_lock.<locals>._needs_document_lock_wrapper() done, defined at C:\Users\shh\miniconda3\envs\holoviz\lib\site-packages\bokeh\server\session.py:51> exception=RuntimeError('Slider.value_throttled is a readonly property')>)
Traceback (most recent call last):
  File "C:\Users\shh\miniconda3\envs\holoviz\lib\site-packages\tornado\ioloop.py", line 741, in _run_callback
    ret = callback()
  File "C:\Users\shh\miniconda3\envs\holoviz\lib\site-packages\tornado\ioloop.py", line 765, in _discard_future_result
    future.result()
  File "C:\Users\shh\miniconda3\envs\holoviz\lib\site-packages\bokeh\server\session.py", line 71, in _needs_document_lock_wrapper
    result = await result
  File "C:\Users\shh\miniconda3\envs\holoviz\lib\site-packages\tornado\gen.py", line 216, in wrapper
    result = ctx_run(func, *args, **kwargs)
  File "c:\users\shh\development\holoviz\panel\panel\reactive.py", line 249, in _change_coroutine
    self._change_event(doc)
  File "c:\users\shh\development\holoviz\panel\panel\reactive.py", line 259, in _change_event
    self._process_events(events)
  File "c:\users\shh\development\holoviz\panel\panel\reactive.py", line 242, in _process_events
    self.param.set_param(**self._process_property_change(events))
  File "C:\Users\shh\miniconda3\envs\holoviz\lib\site-packages\param\parameterized.py", line 1472, in set_param
    self_._batch_call_watchers()
  File "C:\Users\shh\miniconda3\envs\holoviz\lib\site-packages\param\parameterized.py", line 1611, in _batch_call_watchers
    self_._execute_watcher(watcher, events)
  File "C:\Users\shh\miniconda3\envs\holoviz\lib\site-packages\param\parameterized.py", line 1573, in _execute_watcher
    watcher.fn(*args, **kwargs)
  File "c:\users\shh\development\holoviz\panel\panel\reactive.py", line 230, in _param_change
    self._update_model(events, msg, root, model, doc, comm)
  File "c:\users\shh\development\holoviz\panel\panel\reactive.py", line 192, in _update_model
    model.update(**msg)
  File "C:\Users\shh\miniconda3\envs\holoviz\lib\site-packages\bokeh\core\has_props.py", line 440, in update
    setattr(self, k, v)
  File "C:\Users\shh\miniconda3\envs\holoviz\lib\site-packages\bokeh\core\has_props.py", line 297, in __setattr__
    super().__setattr__(name, value)
  File "C:\Users\shh\miniconda3\envs\holoviz\lib\site-packages\bokeh\core\property\descriptors.py", line 550, in __set__
    raise RuntimeError(f"{class_name}.{self.name} is a readonly property")
RuntimeError: Slider.value_throttled is a readonly property

If I change the FloatSlider to the following it works as expected.

class FloatSlider(ContinuousSlider):

    start = param.Number(default=0.0)

    end = param.Number(default=1.0)

    value = param.Number(default=0.0)

    value_throttled = param.Number(default=None, constant=True)

    step = param.Number(default=0.1)

    # _rename = {'name': 'title', 'value_throttled': None}
    _rename = {'name': 'title'}

    def _update_model(self, events, msg, root, model, doc, comm):
        if "value_throttled" in msg:
            del msg["value_throttled"]

        return super()._update_model(events, msg, root, model, doc, comm)
2 Likes

I just tried and it works great !!! Thanks !! I will report it as a bug.

The first time I saw this error was with a IntRangeSlider widget, and in the implementation of the different sliders,watching the implementation of the throttled value changes a lot. I will give a look to try the other sliders.

Thank you very much again !

1 Like