Hello all,
I am new to Bokeh. I would like to discuss a particular application scenario.
I have a class TopClass. Its constructor initializes the document instance. In the constructor, some more objects are initialized, each of them represents a plot to be added in the Doc. Once, TopClass is initialized, I would call TopClass.run(). It will run a simulation and will update the data through the stream. Now, this TopClass is defined in a Python file which has main. Now, I would like to start a server from the Python file itself. Please see the example below:
class TopClass ():
def __init__(self, doc):
self.doc = doc
self.session = push_session(self.doc)
print self.session.id
self.plot1 = plot1(range1, frequency1)
self.plot2 = plot2(range2, frequency2)
def main():
tb = TopClass(doc)
tb.start() ## This is not a blocking function. This is to show the sequence.
tb.stop()
tb.wait()
``
So, now I’d like to run only this Python file. It should initialize an Application, with a server and all. I think we can do something like this:
def main():
loop = IOLoop.current()
handler = FunctionHandler(TopClass.__init__)
app = Application(handler)
server = Server({"/":app}, io_loop = loop)
loop.add_callback(tb.start)
loop.add_callback(server.show, "/")
loop.start()
tb.stop()
tb.wait()
``
Now, as expected, this should fail. What I am interested in: python temp.py should start the server and set up the plots and Documents. If I call localhost:5006/?session=___, it should display the live plots. Through this previous example of main function, I’d like to suggest the use of IOloop, Server, and all. I need a blocking function like loop.start or server.run_until_shutdown. As soon as it stops with Ctrl+C, the simulation will be stopped. I tried some try and error with lots of ways, but not successful. Can anyone suggest me a more appropriate way to implement this? Maybe an example of some reference will be good, too.
Thank you.