balls_bokeh_serve.py 文件源码

python
阅读 17 收藏 0 点赞 0 评论 0

项目:gym-sandbox 作者: suqi 项目源码 文件源码
def __init__(self, map_size, team_size):
        # start bokeh server if it doesn't exist
        # note: there should be only one process to update the session, otherwise chaos
        # TODO: this process will not be closed when main process quit, but it doesn't matter
        # must wait this serve process to run up then we can draw
        try:
            requests.get("http://localhost:5006")
        except Exception as e:
            subprocess.Popen(['bokeh', 'serve'], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
            print(">> waiting for bokeh server starting, 5 seconds...")
            time.sleep(5)
            print(">> here we go!")

        self.draw_init_plot(map_size, team_size)

        # curdoc().add_root(plt_combo)
        # open a session to keep our local document in sync with server
        session = push_session(curdoc())
        session.show(self.plt_combo)  # open the document in a browser
        # session.loop_until_closed()  # run forever

    # def update_plots(self, env_state_action):
    #     """update bokeh plots according to new env state and action data"""
    #     curdoc().add_next_tick_callback(partial(self.update_bokeh_doc, env_state_action=env_state_action))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号