I have been working with a multipage app (refer to this article in the documentation if you don’t understand what I mean). Each page has its own separate widgets which are effectively filters. When loading each of these pages and using these filters, it is almost as if the Bokeh gods decide if a filter will go through or if your server will break down.
Sometimes it is something quite reasonable (me saying this should give you an idea of how my experience with using Bokeh in non-traditional workflows has been) and I get an error like
RuntimeError: _pending_writes should be non-None when we have a document lock, and we should have the lock when the document changes, to which all one has to do is just select the widget again and voila it works without any problem.
Sometimes, however, I get an error from Bokeh’s end, for something that has worked before that instead spits out
AttributeError: 'Document' object has no attribute '_theme' and completely breaks the server, requiring a full shutdown and restart. For this example, by the way, all I did was
hv.render([ANY Holoviews plot]) and as it goes down the execution chain to eventually Bokeh it breaks on Bokeh’s end.
This is completely unacceptable for production apps which sure might break but not on every run, and certainly not after maybe a few minutes of use. I am not sure how to address these kinds of issues and was hoping someone more experienced in the Holoviz community can lend a hand.
Something I forgot to add is that some of my Bokeh plots bound to a widget will eventually shrink to maybe a few pixels in height and stay that way no matter what widget value is chosen. Here is a small example, where the default value is using a “Day” interval:
I then select the “Month” one, so far so good:
Choosing exactly 1 more yields no problem, it can be any of the options. However, by the 4th time, I always get this:
I should note here that the title is actually a
pn.pane.HTML for unrelated reasons, otherwise when it used to be part of the Bokeh plot it would disappear as well.
Now, for the life of my I cannot guess why this happens. To illustrate the above example and how odd it is, I have tried to store the chart by
pn.bind-ing the widget to a
plot function that would resample the dataset based on the value and return a
pn.pane.Bokeh chart to be rendered. I would return the whole thing inside a
pn.Column component. Later I figured it would be faster to have everything pre-rendered, so instead I set the values of the widget to the rendered
plot() functions with the appropriate inputs, and instead changed my
pn.bind from something like this
pn.bind(plot,widget) to this
pn.bind(lambda x: x, widget) since what widget would actually input was
widget.value which was appropriately my plot.
Having tried these both and seeing it doesn’t necessarily have to do with the widget, but rather switching between Bokeh plots helps me realize this is actually a problem with Bokeh and not Panel. I have taken the time to raise this in Bokeh’s discourse but thought the Panel community would benefit from knowing such bugs exist. I unfortunately don’t know how to fix this, so if anyone has any advice it would greatly be appreciated.