Provide the Application class.
Application
Application instances are factories for creating new Bokeh Documents.
When a Bokeh server session is initiated, the Bokeh server asks the Application for a new Document to service the session. To do this, the Application first creates a new empty Document, then it passes this new Document to the modify_document method of each of its handlers. When all handlers have updated the Document, it is used to service the user session.
modify_document
An Application is a factory for Document instances.
__init__
Application factory.
handlers (seq[Handler]) – List of handlers to call. The URL is taken from the first one only.
metadata (dict) –
arbitrary user-supplied JSON data to make available with the application.
The server will provide a URL http://applicationurl/metadata which returns a JSON blob of the form:
http://applicationurl/metadata
{ "data": { "hi": "hi", "there": "there" }, "url": "/myapp" }
The user-supplied metadata is returned as-is under the "data" key in the blob.
"data"
add
Add a handler to the pipeline used to initialize new documents.
handler (Handler) – a handler for this Application to use to process Documents
create_document
Creates and initializes a document using the Application’s handlers.
initialize_document
Fills in a new document using the Application’s handlers.
on_server_loaded
Invoked to execute code when a new session is created.
This method calls on_server_loaded on each handler, in order, with the server context passed as the only argument.
on_server_unloaded
Invoked to execute code when the server cleanly exits. (Before stopping the server’s IOLoop.)
IOLoop
This method calls on_server_unloaded on each handler, in order, with the server context passed as the only argument.
Warning
In practice this code may not run, since servers are often killed by a signal.
on_session_created
This method calls on_session_created on each handler, in order, with the session context passed as the only argument.
May return a Future which will delay session creation until the Future completes.
Future
on_session_destroyed
Invoked to execute code when a session is destroyed.
This method calls on_session_destroyed on each handler, in order, with the session context passed as the only argument.
Afterwards, session_context.destroyed will be True.
session_context.destroyed
True
process_request
Processes incoming HTTP request returning a dictionary of additional data to add to the session_context.
request – HTTP request
A dictionary of JSON serializable data to be included on the session context.
handlers
The ordered list of handlers this Application is configured with.
metadata
Arbitrary user-supplied metadata to associate with this application.
safe_to_fork
static_path
Path to any (optional) static resources specified by handlers.
ServerContext
A harness for server-specific information and tasks related to collections of Bokeh sessions.
This base class is probably not of interest to general users.
add_next_tick_callback
Add a callback to be run on the next tick of the event loop.
Subclasses must implement this method.
callback (callable) –
a callback to add
The callback will execute on the next tick of the event loop, and should have the form def callback() (i.e. it should not accept any arguments)
def callback()
an ID that can be used with remove_next_tick_callback.
remove_next_tick_callback
add_periodic_callback
Add a callback to be run periodically until it is removed.
The callback will execute periodically on the event loop as specified, and should have the form def callback() (i.e. it should not accept any arguments)
period_milliseconds (int) – number of milliseconds to wait between executing the callback.
an ID that can be used with remove_periodic_callback.
remove_periodic_callback
add_timeout_callback
Add a callback to be run once after timeout_milliseconds.
The callback will execute once on the event loop after the timeout has passed, and should have the form def callback() (i.e. it should not accept any arguments)
timeout_milliseconds (int) – number of milliseconds to wait before executing the callback.
an ID that can be used with remove_timeout_callback.
remove_timeout_callback
Remove a callback added with add_next_tick_callback, before it runs.
callback_id – the ID returned from add_next_tick_callback
Removes a callback added with add_periodic_callback.
callback_id – the ID returned from add_periodic_callback
Remove a callback added with add_timeout_callback, before it runs.
callback_id – the ID returned from add_timeout_callback
sessions
SessionContext instances belonging to this application.
SessionContext
A harness for server-specific information and tasks related to Bokeh sessions.
with_locked_document
Runs a function with the document lock held, passing the document to the function.
func (callable) – function that takes a single parameter (the Document) and returns None or a Future
None
a Future containing the result of the function
destroyed
If True, the session has been discarded and cannot be used.
A new session with the same ID could be created later but this instance will not come back to life.
id
The unique ID for the session associated with this context.
server_context
The server context for this session context