def __init__(self, scope): super(BokehAppHTTPConsumer, self).__init__(scope) kwargs = self.scope['url_route']["kwargs"] self.application_context = kwargs["application_context"] # self.application_context._loop = asyncio.get_event_loop() # should use Torado wrapper for asyncio.get_event_loop() event_loop = AsyncIOMainLoop() event_loop.initialize() self.application_context._loop = event_loop self.bokeh_websocket_path = kwargs["bokeh_websocket_path"]