Hello all,
I am trying to connect a simulator output stream to Bokeh. I am creating a server as mentioned at this link.
class TopClass (TopBlock):
def init(self, doc):
self.doc = doc
# Two constructors that create a plot and many plot specific things like ColumnDataSource and all.
# Also added a **doc.periodic_callback **during **initialisation **of the plot which gets data from simulator and
# send to Plot at every 10 ms.
self.plot1 = plot1(range1, frequency1)
self.plot2 = plot2(range2, frequency2)
self.textInput = TextInput(value="value", title="Yaxis")
self.textInput.on_change('value', self.print)
self.doc.add_root(column(self.textInput, self.plot1.plot, self.plot2.plot)) # self.plot1.plot is the correct Bokeh model
def print(self,attr,old,new):
print new
def main(top_block_cls=top_block, options=None):
Define tornado loop
loop = IOLoop()
Define a blank application
app = Application()
Starting server at port 5006
srv = Server({’/’:app},io_loop=loop)
Start server process
srv.start()
Define the document instance
doc = curdoc()
session = push_session(doc, session_id=“test”, io_loop=loop, url=‘http://localhost:5006/’)
Create Top Block instance
tb = top_block_cls(doc)
Start simulations as soon as the server starts
loop.add_callback(tb.start)
loop.add_callback(srv.show,’/?bokeh-session-id=’+str(session.id))
try:
loop.start()
except KeyboardInterrupt:
print “Exiting the simulation. Stopping Bokeh Server”
except Exception as e:
print str(e)
finally:
# Stop the simulations when there is a key interrupt
tb.stop()
tb.wait()
``
``
Again, the issue is: TextInput on_change
callback is never triggered. I am using Bokeh 0.12.6, Tornado 4.4, Ubuntu GNOME 16.04.
I found this issue most relevant. But the solution can not be implemented as suggested there.
Some points to note:
-
This is a bokeh server application. On various possible solutions, they mentioned using non-server application. Can’t do it in my case.
-
The callback function should be pure Python function. I can not make it a CustomJS. The application shown here is basic.
-
Please check the
Application()
and procedure ofServer.start
. Is this issue can be because of that? -
I can see the TextBox value updated in all open instances of the document. That means the update is being spread via the server to all connected clients.
Thank you for your help. Let me know if any further information is needed.