bokeh.server.tornado

Provides the Bokeh Server Tornado application.

class BokehTornado(applications, prefix=None, extra_websocket_origins=None, extra_patterns=None, secret_key=None, sign_sessions=False, generate_session_ids=True, keep_alive_milliseconds=37000, check_unused_sessions_milliseconds=17000, unused_session_lifetime_milliseconds=15000, stats_log_frequency_milliseconds=15000, mem_log_frequency_milliseconds=0, use_index=True, redirect_root=True, **kwargs)[source]

A Tornado Application used to implement the Bokeh Server.

Parameters:
  • applications (dict[str,Application] or Application) –

    A map from paths to Application instances.

    If the value is a single Application, then the following mapping is generated:

    applications = { '/' : applications }
    

    When a connection comes in to a given path, the associate Application is used to generate a new document for the session.

  • prefix (str, optional) – A URL prefix to use for all Bokeh server paths. (default: None)
  • extra_websocket_origins (list[str], optional) –

    A list of hosts that can connect to the websocket.

    This is typically required when embedding a Bokeh server app in an external web site using server_document() or similar.

    If None, ["localhost"] will be assumed (default: None)

  • extra_patterns (seq[tuple], optional) –

    A list of tuples of (str, http or websocket handler)

    Use this argument to add additional endpoints to custom deployments of the Bokeh Server.

    If None, then [] will be used. (default: None)

  • secret_key (str, optional) –

    A secret key for signing session IDs.

    Defaults to the current value of the environment variable BOKEH_SECRET_KEY

  • sign_sessions (bool, optional) –

    Whether to cryptographically sign session IDs

    Defaults to the current value of the environment variable BOKEH_SIGN_SESSIONS. If True, then secret_key must also be provided (either via environment setting or passed as a parameter value)

  • generate_session_ids (bool, optional) – Whether to generate a session ID if one is not provided (default: True)
  • keep_alive_milliseconds (int, optional) –

    Number of milliseconds between keep-alive pings (default: 37000)

    Pings normally required to keep the websocket open. Set to 0 to disable pings.

  • check_unused_sessions_milliseconds (int, optional) – Number of milliseconds between checking for unused sessions (default: 17000)
  • unused_session_lifetime_milliseconds (int, optional) – Number of milliseconds for unused session lifetime (default: 15000)
  • stats_log_frequency_milliseconds (int, optional) – Number of milliseconds between logging stats (default: 15000)
  • mem_log_frequency_milliseconds (int, optional) –

    Number of milliseconds between logging memory information (default: 0)

    Enabling this feature requires the optional depenency psutil to be installed.

  • use_index (bool, optional) – Whether to generate an index of running apps in the RootHandler (default: True)
  • redirect_root (bool, optional) –

    When there is only a single running application, whether to redirect requests to "/" to that application automatically (default: True)

    If there are multiple Bokeh applications configured, this option has no effect.

Any additional keyword arguments are passed to tornado.web.Application.

get_session(app_path, session_id)[source]

Get an active a session by name application path and session ID.

Parameters:
  • app_path (str) – The configured application path for the application to return a session for.
  • session_id (str) – The session ID of the session to retrieve.
Returns:

ServerSession

get_sessions(app_path)[source]

Gets all currently active sessions for an application.

Parameters:app_path (str) – The configured application path for the application to return sessions for.
Returns:list[ServerSession]
initialize(io_loop)[source]

Start a Bokeh Server Tornado Application on a given Tornado IOLoop.

resources(absolute_url=None)[source]

Provide a Resources that specifies where Bokeh application sessions should load BokehJS resources from.

Parameters:absolute_url (bool) – An absolute URL prefix to use for locating resources. If None, relative URLs are used (default: None)
start()[source]

Start the Bokeh Server application.

Starting the Bokeh Server Tornado application will run periodic callbacks for stats logging, cleanup, pinging, etc. Additionally, any startup hooks defined by the configured Bokeh applications will be run.

stop(wait=True)[source]

Stop the Bokeh Server application.

Parameters:wait (bool) – whether to wait for orderly cleanup (default: True)
Returns:None
app_paths

A list of all application paths for all Bokeh applications configured on this Bokeh server instance.

generate_session_ids

Whether this Bokeh Server Tornado Application has been configured to automatically generate session IDs.

io_loop

The Tornado IOLoop that this Bokeh Server Tornado Application is running on.

prefix

A URL prefix for this Bokeh Server Tornado Application to use for all paths

secret_key

A secret key for this Bokeh Server Tornado Application to use when signing session IDs, if configured.

sign_sessions

Whether this Bokeh Server Tornado Application has been configured to cryptographically sign session IDs

If True, then secret_key must also have been configured.

websocket_origins

A list of websocket origins permitted to connect to this server.