bokeh.server.contexts¶
Provides the Application, Server, and Session context classes.
-
class
ApplicationContext(application, io_loop=None, url=None)[source]¶ Server-side holder for
bokeh.application.Applicationplus any associated data. This holds data that’s global to all sessions, whileServerSessionholds data specific to an “instance” of the application.
-
class
BokehServerContext(application_context)[source]¶ -
add_next_tick_callback(callback)[source]¶ Add a callback to be run on the next tick of the event loop.
Subclasses must implement this method.
- Parameters
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)- Returns
an ID that can be used with
remove_next_tick_callback.
-
add_periodic_callback(callback, period_milliseconds)[source]¶ Add a callback to be run periodically until it is removed.
Subclasses must implement this method.
- Parameters
callback (callable) –
a callback to add
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.
- Returns
an ID that can be used with
remove_periodic_callback.
-
add_timeout_callback(callback, timeout_milliseconds)[source]¶ Add a callback to be run once after timeout_milliseconds.
Subclasses must implement this method.
- Parameters
callback (callable) –
a callback to add
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.
- Returns
an ID that can be used with
remove_timeout_callback.
-
remove_next_tick_callback(callback_id)[source]¶ Remove a callback added with
add_next_tick_callback, before it runs.Subclasses must implement this method.
- Parameters
callback_id – the ID returned from
add_next_tick_callback
-
remove_periodic_callback(callback_id)[source]¶ Removes a callback added with
add_periodic_callback.Subclasses must implement this method.
- Parameters
callback_id – the ID returned from
add_periodic_callback
-
remove_timeout_callback(callback_id)[source]¶ Remove a callback added with
add_timeout_callback, before it runs.Subclasses must implement this method.
- Parameters
callback_id – the ID returned from
add_timeout_callback
-
sessions¶ SessionContextinstances belonging to this application.Subclasses must implement this method.
-
-
class
BokehSessionContext(session_id, server_context, document)[source]¶ -
with_locked_document(func)[source]¶ Runs a function with the document lock held, passing the document to the function.
Subclasses must implement this method.
- Parameters
func (callable) – function that takes a single parameter (the Document) and returns
Noneor aFuture- Returns
a
Futurecontaining 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.
-