Figranium client you use a plain for loop. On AsyncFigranium you use async for. Both return the same StreamEvent shape.
Streams
Both take an optional
options keyword argument (headers, timeout).
StreamEvent shape
json.loads on the data lines. If parsing fails, data is the raw string and raw still contains the original payload.
Consume execution events
1
Create a client
Initialize the SDK with your API key.
filename.py
2
Iterate the stream
Use a Iteration ends when the server closes the connection or when your loop breaks. Breaking out of the loop cancels the underlying reader.
for loop to consume events as they arrive.filename.py
Async execution stream
OnAsyncFigranium, use async for:
filename.py
Terminal timeouts
Streams have no default timeout. Settimeout only when you want a hard deadline; the stream raises FigraniumError(code="REQUEST_ABORTED") when the timer fires:
filename.py
Cancel a stream
In Python, cancellation is done by breaking out of the loop or by the terminaltimeout expiring. There is no AbortSignal equivalent.
filename.py
Selector stream from a headful browser
The selector stream reports element highlights from a headful browser session. Use it to power visual inspectors:filename.py
Errors
Streams raiseFigraniumError in the same conditions as regular requests:
REQUEST_ABORTED: the terminaltimeoutfired.NETWORK_ERROR: the stream could not reach the server.