Hi!
I have Bokeh Server embedded into Tornado application, like:
Tornado Server:
io_loop = tornado.ioloop.IOLoop.current()
bokeh_server = get_bokeh_server(io_loop, {’/bokeh/app’: AppHandler.get_bokeh_app()})
bokeh_server.start(start_loop=False)
``
Bokeh Server:
def get_bokeh_server(io_loop, bokeh_applications: dict):
server = Server(bokeh_applications,
io_loop=io_loop, allow_websocket_origin=['xxx.xxx.xxx.xxx:8888']) # NOTE this is my real static IP
return server
Application:
class AppHandler(BaseHandler):
@staticmethod
def modify_doc(doc):
source = ColumnDataSource(dict(xxx=, yyy=))
columns = [
TableColumn(field=“xxx”, title=“xxx”),
TableColumn(field=“yyy”, title=“YYY”)
]
data_table = DataTable(source=source, columns=columns)
def update_handler(*args, **kwargs):
print(“called update_handler”)
update_button = Button(label=“Update”, button_type=“success”)
update_button.on_click(update_handler)
doc.add_root(column(widgetbox(data_table), widgetbox(update_button)))
_bokeh_app = None
@classmethod
def get_bokeh_app(cls):
if cls._bokeh_app is None:
cls._bokeh_app = bokeh.application.Application(FunctionHandler(AppHandler.modify_doc))
return cls._bokeh_app
Tornado page handler:
class TornadoPageHandler(BaseHandler):
@gen.coroutine
def get(self):
user = self.current_user
bs= client.pull_session(session_id=user_id,
url=‘http://xxx.xxx.xxx.xxx:5006’,
app_path=’/bokeh/app’)
user_by_bokeh_session_id[bs.id] = user
doc_script = autoload_server(model=None, session_id=bs.id,
url=‘http://localhost:5006/bokeh/app’
)
self.render(
‘mypage_template.html’,
doc_script=doc_script
)
``
autoload_server works, but client.pull_session cause OSError: Cannot push session document because we failed to connect to the server (to start the server, try the ‘bokeh serve’ command)
when Bokeh application is really available at localhost:5006/bokeh/app
what is going wrong?