bokeh.client.connection#

实现了一个非常低级别的设施,用于与Bokeh服务器进行通信。

用户通常会希望使用ClientSession来进行标准操作。

class ClientConnection(session: ClientSession, websocket_url: str, io_loop: IOLoop | None = None, arguments: dict[str, str] | None = None, max_message_size: int = 20971520)[source]#

用于连接到Bokeh服务器的低级类。

__init__(session: ClientSession, websocket_url: str, io_loop: IOLoop | None = None, arguments: dict[str, str] | None = None, max_message_size: int = 20971520) None[source]#

打开与服务器的websocket连接。

close(why: str = 'closed') None[source]#

关闭Websocket连接。

force_roundtrip() None[source]#

强制向服务器发送往返请求/回复,有时需要避免竞争条件。主要用于测试。

在测试套件之外,此方法会损害性能,不应被需要。

Returns:

loop_until_closed() None[source]#

执行一个阻塞循环,该循环运行并执行事件回调,直到连接关闭(例如,通过按下Ctrl-C)。

虽然此方法可用于在Bokeh服务器“外部”运行Bokeh应用程序代码,但对于任何实际使用情况,这种做法是强烈不推荐的。

pull_doc(document: Document) None[source]#

从服务器拉取文档,覆盖传入的文档

Parameters:

document – (Document) 要用服务器内容覆盖的文档。

Returns:

push_doc(document: Document) Message[Any][source]#

将文档推送到服务器,覆盖任何现有的服务器端文档。

Parameters:

document – (Document) 要推送到服务器的文档

Returns:

服务器回复

request_server_info() ServerInfo[source]#

请求有关服务器的信息。

Returns:

服务器属性的字典。

property connected: bool#

我们是否已经连接了Websocket并交换了初始握手消息。

property error_code: int | None#

如果存在导致断开连接的错误,此属性将保存错误代码。否则为None。

property error_detail: str#

如果存在导致断开连接的错误,此属性将保存错误详细信息。否则为空字符串。

property error_reason: ErrorReason | None#

连接丢失的原因编码为DISCONNECTED.ErrorReason枚举值

property io_loop: IOLoop#

此连接正在使用的Tornado IOLoop

property url: str#

此连接所指向的websocket的URL。