跳转到正文

packet_subscriptions API ​

完整接口目录 · 协议包用法 · 工具包下载

模块说明 ​

text
Selected inbound packet subscriptions, separate from raw diagnostics.

Authorization is checked when the Host delivers a batch. Local iteration does
not reauthorize data already delivered. No reconnect, retry or raw fallback.

MAX_EVENTS ​

python
MAX_EVENTS = 64

MAX_BYTES ​

python
MAX_BYTES = 512 << 10

PacketSubscriptionError ​

python
class PacketSubscriptionError(ProtocolError)

SDK 说明:

text
The selected stream ended; ``reason`` identifies its terminal cause.

PacketSubscriptionError.__init__ ​

python
def __init__(self, reason)

PacketSubscriptionError.reason ​

python
self.reason

公开实例属性,在 __init__ 中设置。

TypedPacketEvent ​

python
@dataclass(frozen=True)
class TypedPacketEvent

字段(包含继承字段):

TypedPacketEvent.sequence ​

python
sequence: int

数据类字段;声明于 packet_subscriptions.TypedPacketEvent。

TypedPacketEvent.packet_id ​

python
packet_id: int

数据类字段;声明于 packet_subscriptions.TypedPacketEvent。

TypedPacketEvent.model ​

python
model: object

数据类字段;声明于 packet_subscriptions.TypedPacketEvent。

TypedPacketEvent.connection_id ​

python
connection_id: str

数据类字段;声明于 packet_subscriptions.TypedPacketEvent。

TypedPacketEvent.schema_hash ​

python
schema_hash: str

数据类字段;声明于 packet_subscriptions.TypedPacketEvent。

TypedPacketEvent.protocol_version ​

python
protocol_version: int

数据类字段;声明于 packet_subscriptions.TypedPacketEvent。

TypedPacketEvent.codec_revision ​

python
codec_revision: int

数据类字段;声明于 packet_subscriptions.TypedPacketEvent。

TypedPacketEvent.observed_at ​

python
observed_at: str

数据类字段;声明于 packet_subscriptions.TypedPacketEvent。

PacketSubscription ​

python
class PacketSubscription

SDK 说明:

text
Lazy async context manager, batch reader and serial async iterator.

``close`` discards local buffered events, joins an in-flight local read and
requests Host closure. A failed/timed-out IPC does not prove remote closure.
``listen`` returns a Worker-owned task; cancel and await it to stop callbacks.

PacketSubscription.__init__ ​

python
def __init__(
    self,
    context,
    packet_types,
    *,
    max_events = MAX_EVENTS,
    max_bytes = MAX_BYTES,
    poll_interval = 0.025,
)

PacketSubscription.snapshot ​

python
@property
def snapshot(self)

PacketSubscription.open ​

python
async def open(self)

PacketSubscription.poll_batch ​

python
async def poll_batch(self, *, max_events=None, max_bytes=None)

SDK 说明:

text
Return available selected events; [] means idle. Bounds apply to IPC.

PacketSubscription.__aiter__ ​

python
def __aiter__(self)

PacketSubscription.__anext__ ​

python
async def __anext__(self)

PacketSubscription.listen ​

python
async def listen(self, callback)

SDK 说明:

text
Start one Worker-owned serial callback task and return it.

PacketSubscription.close ​

python
async def close(self)

PacketSubscription.__aenter__ ​

python
async def __aenter__(self)

PacketSubscription.__aexit__ ​

python
async def __aexit__(self, *_)

Neomega · 使用、开发与参考文档