I have a CDS that I use for both the rectangle glyph and the DataTable widget. I would like to update the rectangle color when I manually modify a value in the table (not color value). The procedure should be that I modify a value of the column ‘foo’ manually in the table, it triggers a callback to change the value of the ‘fill_color’ column, which should update the rectangle color. So I put an on_change event on the source, but I run into the infinite recursion problem. I run a bokeh server, so Python callbacks are preferred. So now in the callback I’m trying to directly modify some values in the source (which will not trigger full data change callback), but I can’t find a way to just ‘silently’ update the plot with my modified source. Is the a way to just trigger the plot update/rerendering? Or any other way to approach this issue?
As a workaround, I do
remove_on_change at the beginning of the callback function, and then add again
on_change in the end, to prevent infinite recursion. But it would be nice to have some more elegant solution.
This situation is not unique to Bokeh. AFAIK the options are always more or less:
- avoid recursion by redesigning the system to avoid the dependency cycle altogether
- manually halt recursion (e.g. by disabling callbacks as you have, or by setting/checking an “in flight” flag)