You can use lifecycle hooks in a Flask context, but it is an advanced and uncommon thing to do, and does not have all the conveniences that the “directory format” bokeh server apps with an app_hooks.py file has. You will have to create an actual handler class to configure on the application:
from bokeh.application import Application
from bokeh.application.handlers import FunctionHandler
from bokeh.application.handlers.lifecycle import LifecycleHandler
class MyHandler(LifecycleHandler):
def on_server_loaded(self, server_context):
print("SERVER LOADED")
bkapp = Application(FunctionHandler(bkapp), MyHandler())
As for sharing data created in the server loaded hook, there’s a near infinite range of possibilities, from a shared database each session connects to, to pre-processed files that every session loads. Alternatively you can use Python a module that all sessions import. Have the hook store some module global and then all sessions that import the module will automatically see that immediately simply due to how Python itself caches modules. The spectrogram example does this with an audio.py module:
https://github.com/bokeh/bokeh/tree/branch-2.2/examples/app/spectrogram
This is really terrible that I can’t have multiple users use this app on Windows?
You can certainly have multiple users, in general. I just opened the bokeh serve --show sliders.py example on Windows and then opened 10 simultaneous windows. That’s just with one process, since the actual work the app does in callbacks is minimal. But if there is a long server startup time, or long individual session startup time, expensive blocking work in callbacks, all of these things will point towards more sophisticated approaches. Bokeh is not magic. If there is 10 minutes of startup time Bokeh can’t make that disappear. Whether and how things might become more involved and sophisticated to deal with situations like that depends on the actual specifics of what kind of work the app does, about which we know almost nothing.
Do you know if there’s any sort of bokeh support phone number I can call?
I would really appreciate some support here.
I just have to reiterate that Bokeh is an open source project run on a volunteer basis, not a business of any sort.