You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I ran into an unusual situation where I set up a simple Panel UI to run inside a Jupyter notebook, and then tried to update the data for the UI from a background thread. I observed that several updates would work properly, but at some point, Panel would try to update the value of a numeric param to be an HTML string (seemingly from a pn.widgets.StaticText) which would throw an exception and stop the UI from updating.
ALL software version info
Python: 3.11.9
OS: Mac OSX 14.5 on M3 Max
Browser: Chrome 126.0.6478.183 (Official Build) (arm64)
Description of expected behavior and the observed behavior
It should be possible to update parameterized models from a background thread and have the UI update without issue.
Instead, when I trigger the background thread to update the model repeatedly, at some point Panel handles a message which is trying to set the model's value to be an HTML string, rather than the raw number.
It seems that this may come from the pn.widgets.StaticText widget - if I comment out and only display the position via pn.widgets.FloatSlider, I did not observe this problem in my repro case.
Complete, minimal, self-contained example code that reproduces the issue
Traceback (most recent call last):
File "/Users/dj/code/panel-thread-repro/venv/lib/python3.11/site-packages/pyviz_comms/__init__.py", line 340, in _handle_msg
self._on_msg(msg)
File "/Users/dj/code/panel-thread-repro/venv/lib/python3.11/site-packages/panel/viewable.py", line 478, in _on_msg
doc.unhold()
File "/Users/dj/code/panel-thread-repro/venv/lib/python3.11/site-packages/bokeh/document/document.py", line 776, in unhold
self.callbacks.unhold()
File "/Users/dj/code/panel-thread-repro/venv/lib/python3.11/site-packages/bokeh/document/callbacks.py", line 432, in unhold
self.trigger_on_change(event)
File "/Users/dj/code/panel-thread-repro/venv/lib/python3.11/site-packages/bokeh/document/callbacks.py", line 409, in trigger_on_change
invoke_with_curdoc(doc, event.callback_invoker)
File "/Users/dj/code/panel-thread-repro/venv/lib/python3.11/site-packages/bokeh/document/callbacks.py", line 444, in invoke_with_curdoc
return f()
^^^
File "/Users/dj/code/panel-thread-repro/venv/lib/python3.11/site-packages/bokeh/util/callback_manager.py", line 185, in invoke
callback(attr, old, new)
File "/Users/dj/code/panel-thread-repro/venv/lib/python3.11/site-packages/panel/reactive.py", line 474, in _comm_change
state._handle_exception(e)
File "/Users/dj/code/panel-thread-repro/venv/lib/python3.11/site-packages/panel/io/state.py", line 458, in _handle_exception
raise exception
File "/Users/dj/code/panel-thread-repro/venv/lib/python3.11/site-packages/panel/reactive.py", line 472, in _comm_change
self._schedule_change(doc, comm)
File "/Users/dj/code/panel-thread-repro/venv/lib/python3.11/site-packages/panel/reactive.py", line 454, in _schedule_change
self._change_event(doc)
File "/Users/dj/code/panel-thread-repro/venv/lib/python3.11/site-packages/panel/reactive.py", line 450, in _change_event
self._process_events(events)
File "/Users/dj/code/panel-thread-repro/venv/lib/python3.11/site-packages/panel/reactive.py", line 387, in _process_events
self.param.update(**self_params)
File "/Users/dj/code/panel-thread-repro/venv/lib/python3.11/site-packages/param/parameterized.py", line 2319, in update
restore = dict(self_._update(arg, **kwargs))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/dj/code/panel-thread-repro/venv/lib/python3.11/site-packages/param/parameterized.py", line 2352, in _update
self_._batch_call_watchers()
File "/Users/dj/code/panel-thread-repro/venv/lib/python3.11/site-packages/param/parameterized.py", line 2546, in _batch_call_watchers
self_._execute_watcher(watcher, events)
File "/Users/dj/code/panel-thread-repro/venv/lib/python3.11/site-packages/param/parameterized.py", line 2506, in _execute_watcher
watcher.fn(*args, **kwargs)
File "/Users/dj/code/panel-thread-repro/venv/lib/python3.11/site-packages/panel/param.py", line 527, in link_widget
self.object.param.update(**{p_name: change.new})
File "/Users/dj/code/panel-thread-repro/venv/lib/python3.11/site-packages/param/parameterized.py", line 2319, in update
restore = dict(self_._update(arg, **kwargs))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/dj/code/panel-thread-repro/venv/lib/python3.11/site-packages/param/parameterized.py", line 2345, in _update
setattr(self_or_cls, k, v)
File "/Users/dj/code/panel-thread-repro/venv/lib/python3.11/site-packages/param/parameterized.py", line 528, in _f
instance_param.__set__(obj, val)
File "/Users/dj/code/panel-thread-repro/venv/lib/python3.11/site-packages/param/parameterized.py", line 530, in _f
return f(self, obj, val)
^^^^^^^^^^^^^^^^^
File "/Users/dj/code/panel-thread-repro/venv/lib/python3.11/site-packages/param/parameters.py", line 543, in __set__
super().__set__(obj,val)
File "/Users/dj/code/panel-thread-repro/venv/lib/python3.11/site-packages/param/parameterized.py", line 530, in _f
return f(self, obj, val)
^^^^^^^^^^^^^^^^^
File "/Users/dj/code/panel-thread-repro/venv/lib/python3.11/site-packages/param/parameterized.py", line 1498, in __set__
self._validate(val)
File "/Users/dj/code/panel-thread-repro/venv/lib/python3.11/site-packages/param/parameters.py", line 828, in _validate
self._validate_value(val, self.allow_None)
File "/Users/dj/code/panel-thread-repro/venv/lib/python3.11/site-packages/param/parameters.py", line 811, in _validate_value
raise ValueError(
ValueError: Number parameter 'PositionView.position' only takes numeric values, not <class 'str'>.```
Screenshots or screencasts of the bug in action
panel.bug.screencast.mov
I may be interested in making a pull request to address this
The text was updated successfully, but these errors were encountered:
I ran into an unusual situation where I set up a simple Panel UI to run inside a Jupyter notebook, and then tried to update the data for the UI from a background thread. I observed that several updates would work properly, but at some point, Panel would try to update the value of a numeric param to be an HTML string (seemingly from a
pn.widgets.StaticText
) which would throw an exception and stop the UI from updating.ALL software version info
Python: 3.11.9
OS: Mac OSX 14.5 on M3 Max
Browser: Chrome 126.0.6478.183 (Official Build) (arm64)
Selected python library versions:
Description of expected behavior and the observed behavior
It should be possible to update parameterized models from a background thread and have the UI update without issue.
Instead, when I trigger the background thread to update the model repeatedly, at some point Panel handles a message which is trying to set the model's value to be an HTML string, rather than the raw number.
It seems that this may come from the
pn.widgets.StaticText
widget - if I comment out and only display the position viapn.widgets.FloatSlider
, I did not observe this problem in my repro case.Complete, minimal, self-contained example code that reproduces the issue
See a minimal repro in repo here: https://github.com/dennisjlee/panel-thread-repro
Stack traceback and/or browser JavaScript console output
Screenshots or screencasts of the bug in action
panel.bug.screencast.mov
The text was updated successfully, but these errors were encountered: