Dear all,
I am working on embeding a bokeh app inside of an already existing tornado app. I saw that it was possible to share the same ioloop, so I have a main that looks like this:
if __name__ == '__main__':
# First instantiate main tornado infrastructure
http_server = tornado.httpserver.HTTPServer(TornadoApplication())
http_server.listen(tornado.options.options.port)
io_loop = tornado.ioloop.IOLoop.current()
# Now instantiate bokeh app
bokeh_server = Server({'/bokeh_app': bokeh_app},
io_loop=io_loop,
allow_websocket_origin=['localhost:8888'])
# Launch the whole thing
io_loop.start()
And somwhere in my tornado handler, I get the generated bokeh script with:
script = server_document('http://localhost:5006/bokeh_app')
The problem is that, I would like to modify (like add points on user post, or add new data upon database update, or any event that might come from tornado).
The only way I found up to now, was to keep a dictionary of existing documents created per each user as a global variable shared both by the tornado handlers and bokeh_app.
As soon as certain event arise within tornado, I fetch the bokeh document with the right key within the dictionary and update it with:
document.add_next_tick_callback(update)
Now the problem that I have no way to share a unique identifier for each user, that would be shared in between tornado (like a cookie) and bokeh like a session id.
My main leads are:
- Try to read a secure cookie from bokeh app ?
- Try to force a session_id when including bokeh inside tornado handler with
server_session
instead ofserver_document
for instance with asession_id
that would be equal to the cookie value
What is in you opinion to do something like this ?
Thank you very much for your help