Streaming¶
Stream backends for receiving execution events from Temporal Workflows.
StreamBackend¶
StreamBackend
¶
Bases: ABC
Abstract base class for stream backends.
Stream backends provide the mechanism for transmitting execution events from the Temporal Workflow to the client across process boundaries.
publish
abstractmethod
async
¶
Publish a stream event.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
workflow_id
|
str
|
The Temporal Workflow ID. |
required |
event
|
Any
|
The stream event to publish. |
required |
subscribe
abstractmethod
¶
Subscribe to stream events for a workflow.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
workflow_id
|
str
|
The Temporal Workflow ID. |
required |
Yields:
| Type | Description |
|---|---|
AsyncIterator[Any]
|
Stream events as they arrive. |
PollingStreamBackend¶
PollingStreamBackend
¶
Bases: StreamBackend
Stream backend using Temporal Query with cursor-based pagination.
This is the default streaming implementation. It polls the Workflow's
get_stream_buffer query at regular intervals to retrieve new events.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
poll_interval
|
float
|
Seconds between polls. Default 0.1. |
0.1
|
Source code in langgraph/temporal/streaming.py
poll_stream
async
¶
poll_stream(
handle: Any,
query_method: Any,
*,
timeout: float | None = None,
) -> AsyncIterator[Any]
Poll a workflow's stream buffer using Temporal Query.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
handle
|
Any
|
The Temporal WorkflowHandle. |
required |
query_method
|
Any
|
The query method reference (e.g.,
|
required |
timeout
|
float | None
|
Maximum time to poll before stopping. |
None
|
Yields:
| Type | Description |
|---|---|
AsyncIterator[Any]
|
Stream events as they arrive. |