I recently updated bokeh from 1.4 to 2.0.0. I have a flask application with several bokeh servers. After updating, the bokeh servers no longer render properly(no plot, blank), there are no errors in the browser console or redhat shell. If I revert back to bokeh 1.4 + tornado 4.5.3, it renders normally. Can someone help me figure out what's happening?
Python 3.6.3 bokeh 2.0.0 tornado 6.0.4 redhat 4.8.5
edit: doing bokeh serve myapp.py
individually for each bokeh server surprisingly works, it must be the way i'm deploying them through flask..the code below works on bokeh1.4 + tornado 4.5.3
# cycle through bokeh files and start bokeh servers
files = []
boks = []
for file in os.listdir("/mypath_to_bokeh/bokehs/"):
if file.endswith('.py'):
boks.append(file)
file = "bokehs/" + file
files.append(file)
boks = [os.path.splitext(x)[0] for x in boks]
argvs = {}
urls = []
for i in files:
argvs[i] = None
urls.append(i.split('\\')[-1].split('.')[0])
host = 'myhost'
apps = build_single_handler_applications(files, argvs)
bokeh_tornado = BokehTornado(apps, extra_websocket_origins=["hoststring"])
bokeh_http = HTTPServer(bokeh_tornado)
sockets, port = bind_sockets("ipstring", 0)
bokeh_http.add_sockets(sockets)
def serve(name):
@app.route("/{}".format(name), endpoint=str(name))
#@login_required
#@bokeh_access
def func():
bokeh_script = server_document("ipstring:%d/%s" % (port, name))
gc.collect()
return render_template("bokserv.html", bokeh_script=bokeh_script)
func.__name__ = name
gc.collect()
return func
all_serve_functions = [serve(name) for name in boks]
something I accidentally omitted from the posted code was that I had at the end of my application:
def bk_worker():
asyncio.set_event_loop(asyncio.new_event_loop())
bokeh_tornado = BokehTornado(apps, extra_websocket_origins=["localhost:8000"])
bokeh_http = HTTPServer(bokeh_tornado)
sockets, port = bind_sockets("localhost", 0) #PROBLEM LINE
bokeh_http.add_sockets(sockets)
server = BaseServer(IOLoop.current(), bokeh_tornado, bokeh_http)
server.start()
server.io_loop.start()
t = Thread(target=bk_worker)
t.daemon = True
t.start()
Extracting out the #PROBLEM LINE
and putting it before the bk_worker()
function returned functionality of bokeh for the most part, now it's time to refactor all the deprecated code.