Hi,
Is it possible to implement a push model for updating bokeh data sources (as opposed to a pull model in AjaxDatasource) where a datasource gets updated by an external caller? I’ve tried writing it using pull_session under the assumption that the session will synchronize states when it closes but that doesn’t seem to be the case. What I’m currently trying is this:
import os,sys,json,time
from datetime import datetime
from flask import jsonify,abort, Flask
from flask_classy import FlaskView, route,request
import logging
from bokeh.client import pull_session, push_session
app = Flask(__name__)
bokeh_url = "http://127.0.0.1:5005/bokeh_server"
class ServerController(FlaskView):
route_base = '/'
@route("/upload",methods=["POST"])
def process(self):
message = json.loads(request.data)
xs= message["x"]
ys = message["y"]
with pull_session(url=bokeh_url) as session:
doc = session.document
#data_source is a ColumnDataSource object defined on the bokeh server
datasource = doc.get_model_by_name("data_source")
datasource.data = {"x":xs, "y": ys}
return ""
ServerController.register(app)
But it seems that the state update is not propagated to the server after the session closes. Any suggestions on whether this is possible?