bokeh.server.server¶
Provide basic Bokeh server objects that use a Tornado HTTPServer and
BokeTornado Tornado Application to service Bokeh Server Applications.
There are two public classes in this module:
BaseServer- This is a lightweight class to explicitly coordinate the components needed
to run a Bokeh server (A
BokehTornadoinstance, and TornadoHTTPServerand a TornadoIOLoop) Server- This higher-level convenience class only needs to be configured with Bokeh
Applicationinstances, and will automatically create and coordinate the lower level Tornado components.
-
class
bokeh.server.server.BaseServer(io_loop, tornado_app, http_server)¶ Explicitly coordinate the level Tornado components required to run a Bokeh server:
- A Tornado
IOLoopto run the Bokeh server machinery. - a
BokehTornadoTornado application that defines the Bokeh server machinery. - a Tornado
HTTPServerto direct HTTP requests
All three of these components must be passed to
BaseServer, which will initialize theBokehTornadoinstance on theio_loop. Thehttp_servermust have been previously created and initialized with theBokehTornadoinstance.-
get_session(app_path, session_id)¶ Get an active a session by name application path and session ID.
Parameters: Returns: ServerSession
-
get_sessions(app_path=None)¶ Gets all currently active sessions for applications.
Parameters: app_path (str, optional) – The configured application path for the application to return sessions for. If None, return active sessions for all applications. (default: None) Returns: list[ServerSession]
-
run_until_shutdown()¶ Run the Bokeh Server until shutdown is requested by the user, either via a Keyboard interrupt (Ctrl-C) or SIGTERM.
Calling this method will start the Tornado
IOLoopand block all execution in the calling process.Returns: None
-
show(app_path, browser=None, new='tab')¶ Opens an app in a browser window or tab.
This method is useful for testing or running Bokeh server applications on a local machine but should not call when running Bokeh server for an actual deployment.
Parameters: - app_path (str) – the app path to open The part of the URL after the hostname:port, with leading slash.
- browser (str, optional) – browser to show with (default: None)
For systems that support it, the browser argument allows
specifying which browser to display in, e.g. “safari”, “firefox”,
“opera”, “windows-default” (see the
webbrowsermodule documentation in the standard lib for more details). - new (str, optional) – window or tab (default: “tab”)
If
newis ‘tab’, then opens a new tab. Ifnewis ‘window’, then opens a new window.
Returns: None
-
start()¶ Install the Bokeh Server and its background tasks on a Tornado
IOLoop.This method does not block and does not affect the state of the Tornado
IOLoopYou must start and stop the loop yourself, i.e. this method is typically useful when you are already explicitly managing anIOLoopyourself.To start a Bokeh server and immediately “run forever” in a blocking manner, see
run_until_shutdown().
-
stop(wait=True)¶ Stop the Bokeh Server.
This stops and removes all Bokeh Server
IOLoopcallbacks, as well as stops theHTTPServerthat this instance was configured with.Parameters: fast (bool) – Whether to wait for orderly cleanup (default: True) Returns: None
-
unlisten()¶ Stop listening on ports. The server will no longer be usable after calling this function.
Returns: None
-
io_loop¶ The Tornado
IOLoopthat this Bokeh Server is running on.
- A Tornado
-
class
bokeh.server.server.Server(applications, io_loop=None, http_server_kwargs=None, **kwargs)¶ A high level convenience class to run a Bokeh server.
This class can automatically coordinate the three the base level components required to run a Bokeh server:
- A Tornado
IOLoopto run the Bokeh server machinery. - a
BokehTornadoTornado application that defines the Bokeh server machinery. - a Tornado
HTTPServerto direct HTTP requests
This high level
Serverclass has some limitations. In particular, it is not possible to set an explicitio_loopandnum_procsother than 1 at the same time. To do that, it is necessary to useBaseServerand coordinate the three components above explicitly.-
address¶ The configured address that the server listens on for HTTP requests.
-
port¶ The configured port number that the server listens on for HTTP requests.
-
prefix¶ The configured URL prefix to use for all Bokeh server paths.
- A Tornado