Hello
I’ve been at this for a couple of weeks now, and I can’t seem to figure it out, however, I feel like I’m really close.
I’ve tried alot of things, but I was able to simplify it to these 2 code snippets.
Here is a code snippet of the file I run with bokeh serve:
curdoc().add_root(fig)
curdoc().add_periodic_callback(…,100)
In my views.py in Django, I do the following (code snippet):
def index(request):
session = pull_session(url = …)
script = server_session(None, session_id = session.id, url = …)
return render(request, …, context = {‘script’ : script})
This works as expected. The plot gets updated and I see live data on the plot. (the data is coming from a sensor connected to the pi).
However, I cannot get multiple users see this plot. “Model must be owned by single document”
After researching, I found a post about this exact problem. I had to add the following in my view:
def index(request):
session = pull_session(url = …)
session.document.roots[0].title.text = “Plot”
session.push()
script = server_session(None, session_id = session.id, url = …)
return render(request, …, context = {‘script’ : script})
I assume session.push() pushes the session.document to the server, creating a new sessionID on the server so that the next person has a unique sessionID, but I’m not sure about this.
Anyhow, multiple users can now connect and all have an unique sessionID, as expected. However, the plots do not update dynamically anymore. If I refresh the page, the data gets added to the plot, but new data doesn’t get streamed anymore.
Could anyone help me with this problem?
Thank you in advance