Provide new session/document on each reload?


I have a question: The behavior I see is that if I reload my bokeh dashboard, it seems to re-use the session so ColumnDataSources will have the data from before the reload in them. This is causing issues because I wrote the code expecting a newly initialized session/document on every load. Can I somehow enforce that always a new session is provided?
This is causing issues because the difference in data sources between a newly initialized session and one with changes isn’t reflected on the dashboard, so there will be a desync between the frontend and backend state. This causes funny behavior. While it might be elegant to the user to continue where they left of, I’d like to disable this for now, because the dashboard doesn’t function properly as of now.

Somehow I didn’t see this when developing, because the server was reloading everytime I made some changes? Also when running this in production with multiple bokeh serve processes, it seems like this behavior only occurs when hitting the ‘right’ process, which served the requests before the reload? Also it seems to occur when opening in the dashboard in a new tab.


Hi @Johannes you will need to provide more information about exactly what your are doing because what you describe is not consistent with my experience.

Yes… I feel a bit embarrassed. What I was observing was that the column data source seemed to ‘remember’ the data from the previous loading of the page. And I couldn’t figure out why, so I thought that was intended (it isn’t).

Why this happened: I have a global dictionary which contains initial data for the data source. This means when data is written into the data source, this also changes my global dictionary, so on the next reload the data source will be initialized with other data, not my expected initial data. I keep this global dictionary around, so I can ‘reset’ the data source in other parts of the code.

Solution: Make a deepcopy before passing the dictionary to ColumnDataSource.

Thanks (again) for your time and input!

1 Like