How to prevent creation of a session on server start?

When I start Bokeh with “bokeh serve DirName --show” I find that session_created is executed twice: once for the --show and once for the server startup.

The one for the server startup does however not make sense in the our use case where we want to see the app only from a web browser.

I tried to skip running on_session_created in the first pass, but then Bokeh raises an error as it still tries to fill in the session document.

Any ideas?

I’m going to assume you are referring to the fact that Bokeh creates a session on the initial HTTP connect, and then, if the subsequent WS connection lands on a different process, then the session creation has to happen again (because the new process does not have access to the session created on the HTTP connect). That’s simply the way the Bokeh server currently operates. Making it do something different would require new feature development work. In particular, there are parts of the session document that are needed as early as the HTTP connect (e.g. any custom template for sure) so some mechanism would have to be found to allow access to that information without a “complete” session execution.

Okay clear thanks, I will seek to minimize work in session creation and move work to server start instead.