Skip to content

Commit

Permalink
Fix obj.save() when threading is enabled (#5993)
Browse files Browse the repository at this point in the history
  • Loading branch information
maximlt authored Dec 5, 2023
1 parent 573497c commit a03726b
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
6 changes: 5 additions & 1 deletion panel/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,11 @@ def __setattr__(self, attr, value):
if not init or (attr.startswith('_') and attr.endswith('_')) or attr == '_validating':
return super().__setattr__(attr, value)
value = getattr(self, f'_{attr}_hook', lambda x: x)(value)
if attr in _config._globals or self.param._TRIGGER:
if (
attr in _config._globals
or (attr.startswith("_") and attr[1:] in _config._globals)
or self.param._TRIGGER
):
super().__setattr__(attr if attr in self.param else f'_{attr}', value)
elif state.curdoc is not None:
if attr in _config._parameter_set:
Expand Down
23 changes: 23 additions & 0 deletions panel/tests/test_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -927,3 +927,26 @@ def test_server_no_warning_empty_layout(port, caplog):
finally:
bk_logger.setLevel(old_level)
bk_logger.propagate = old_propagate


def test_server_threads_save(threads, port, tmp_path):
# https://github.com/holoviz/panel/issues/5957

button = Button()
fsave = tmp_path / 'button.html'

def cb(event):
button.save(fsave)

def simulate_click():
button._comm_event(state.curdoc, ButtonClick(model=None))

button.on_click(cb)

def app():
state.curdoc.add_next_tick_callback(simulate_click)
return button

serve_and_request(app)

wait_until(lambda: fsave.exists())

0 comments on commit a03726b

Please sign in to comment.