bokeh.client.connection#
Implements a very low level facility for communicating with a Bokeh Server.
Users will always want to use ClientSession
instead for standard usage.
- class ClientConnection(session: ClientSession, websocket_url: str, io_loop: IOLoop | None = None, arguments: dict[str, str] | None = None, max_message_size: int = 20971520)[source]#
A low-level class used to connect to a Bokeh server.
Public Data Attributes:
Whether we've connected the Websocket and have exchanged initial handshake messages.
The Tornado
IOLoop
this connection is using.The URL of the websocket this Connection is to.
The reason of the connection loss encoded as a
DISCONNECTED.ErrorReason
enum valueIf there was an error that caused a disconnect, this property holds the error code.
If there was an error that caused a disconnect, this property holds the error detail.
Public Methods:
__init__
(session, websocket_url[, io_loop, ...])Opens a websocket connection to the server.
connect
()close
([why])Close the Websocket connection.
Force a round-trip request/reply to the server, sometimes needed to avoid race conditions.
Execute a blocking loop that runs and executes event callbacks until the connection is closed (e.g.
pull_doc
(document)Pull a document from the server, overwriting the passed-in document
push_doc
(document)Push a document to the server, overwriting any existing server-side doc.
Ask for information about the server.
send_message
(message)
- __init__(session: ClientSession, websocket_url: str, io_loop: IOLoop | None = None, arguments: dict[str, str] | None = None, max_message_size: int = 20971520) None [source]#
Opens a websocket connection to the server.
- force_roundtrip() None [source]#
Force a round-trip request/reply to the server, sometimes needed to avoid race conditions. Mostly useful for testing.
Outside of test suites, this method hurts performance and should not be needed.
- Returns:
None
- loop_until_closed() None [source]#
Execute a blocking loop that runs and executes event callbacks until the connection is closed (e.g. by hitting Ctrl-C).
While this method can be used to run Bokeh application code “outside” the Bokeh server, this practice is HIGHLY DISCOURAGED for any real use case.
- pull_doc(document: Document) None [source]#
Pull a document from the server, overwriting the passed-in document
- Parameters:
document – (Document) The document to overwrite with server content.
- Returns:
None
- push_doc(document: Document) Message[Any] [source]#
Push a document to the server, overwriting any existing server-side doc.
- Parameters:
document – (Document) A Document to push to the server
- Returns:
The server reply
- request_server_info() ServerInfo [source]#
Ask for information about the server.
- Returns:
A dictionary of server attributes.
- property connected: bool#
Whether we’ve connected the Websocket and have exchanged initial handshake messages.
- property error_code: int | None#
If there was an error that caused a disconnect, this property holds the error code. None otherwise.
- property error_detail: str#
If there was an error that caused a disconnect, this property holds the error detail. Empty string otherwise.
- property error_reason: ErrorReason | None#
The reason of the connection loss encoded as a
DISCONNECTED.ErrorReason
enum value
- property io_loop: IOLoop#
The Tornado
IOLoop
this connection is using.