def start_dashboard(dashboard: Dashboard, args: argparse.Namespace) -> None: app = Application() app.add(dashboard) if args.dashboard_allow_websocket_origin: allow_websocket_origin = args.dashboard_allow_websocket_origin else: allow_websocket_origin = [ 'localhost:{}'.format(args.dashboard_port), '{}:{}'.format(args.external_hostname, args.dashboard_port) ] server = Server(app, port=args.dashboard_port, allow_websocket_origin=allow_websocket_origin) server.start()
class BokehPlotter(object): def __init__(self, handlers, port=5006): self.app = Application() for handler in handlers: self.app.add(handler) self.server = Server({'/': self.app}, port=port) self.thread = Thread(target=self.server.io_loop.start) def start(self): self.server.start() self.server.io_loop.add_callback(self.server.show, '/') self.thread.start() def stop(self): self.server.io_loop.stop() self.server.stop() self.thread.join()