First part : the Document
Each document has a (potentially different) tick.
I don’t really understand what this is suggesting. In the code you provided, for any given user session, all the CDS there are all always in one single Document.
I guessed that each webbrowser connecting to the server potentially creates a document → multiple connections creates multiple documents (ie instances of Document
).
I understand this is what you mean, more precisely, by “for any given user session”.
From the doc:
Sessions have a 1-1 relationship with instances of bokeh.document.Document
: each session has a document instance. When a browser connects to the server, it gets a new session
So I potentially have multiple documents to deal with when streaming to update the plots. Even in the code I provided, multiple webbrowser connections will create multiple documents, right ?
Note my Clock
class wants to abstract as much as possible any server internals, the goal is just to encapsulate some dataframe and provide (debug-style) visualization of that data when someones connects to the server.
Second part : the tick
The document has a add_next_tick_callback()
method, so I guessed that each document potentially has a different tick, and therefore has this method (instead of having it somewhere else - like on the server ?).
I am using only one server process in this example here (my immediate usecase), but I am looking for a “generic” design given bokeh design, even if I am not sure of the best way to run multiprocess yet…
But, given that bokeh server is single-threaded, maybe there is a simpler/better way to get the different ticks in my case ? maybe scheduling callbacks on the tick of the server, via https://docs.bokeh.org/en/latest/docs/dev_guide/server.html#lifecycle for example ?