nemo_microservices._streaming
#
Module Contents#
Classes#
Provides the core interface to iterate over an asynchronous stream response. |
|
Provides the core interface to iterate over a synchronous stream response. |
Functions#
Given a type like |
|
TypeGuard for determining whether or not the given type is a subclass of |
API#
- class nemo_microservices._streaming.AsyncStream(
- *,
- cast_to: type[nemo_microservices._streaming._T],
- response: httpx.Response,
- client: nemo_microservices._client.AsyncNeMoMicroservices,
Bases:
typing.Generic
[nemo_microservices._streaming._T
]Provides the core interface to iterate over an asynchronous stream response.
Initialization
- async close() None #
Close the response and release the connection.
Automatically called if the response body is read to completion.
- response: httpx.Response#
None
- class nemo_microservices._streaming.SSEBytesDecoder#
Bases:
typing_extensions.Protocol
- aiter_bytes(
- iterator: AsyncIterator[bytes],
Given an async iterator that yields raw binary data, iterate over it & yield every event encountered
- iter_bytes(
- iterator: Iterator[bytes],
Given an iterator that yields raw binary data, iterate over it & yield every event encountered
- class nemo_microservices._streaming.SSEDecoder#
Initialization
- async aiter_bytes(
- iterator: AsyncIterator[bytes],
Given an iterator that yields raw binary data, iterate over it & yield every event encountered
- decode(
- line: str,
- iter_bytes(
- iterator: Iterator[bytes],
Given an iterator that yields raw binary data, iterate over it & yield every event encountered
- class nemo_microservices._streaming.ServerSentEvent(
- *,
- event: str | None = None,
- data: str | None = None,
- id: str | None = None,
- retry: int | None = None,
Initialization
- property data: str#
- property event: str | None#
- property id: str | None#
- json() Any #
- property retry: int | None#
- class nemo_microservices._streaming.Stream(
- *,
- cast_to: type[nemo_microservices._streaming._T],
- response: httpx.Response,
- client: nemo_microservices._client.NeMoMicroservices,
Bases:
typing.Generic
[nemo_microservices._streaming._T
]Provides the core interface to iterate over a synchronous stream response.
Initialization
- close() None #
Close the response and release the connection.
Automatically called if the response body is read to completion.
- response: httpx.Response#
None
- nemo_microservices._streaming.extract_stream_chunk_type(
- stream_cls: type,
- *,
- failure_message: str | None = None,
Given a type like
Stream[T]
, returns the generic type variableT
.This also handles the case where a concrete subclass is given, e.g.
class MyStream(Stream[bytes]): ... extract_stream_chunk_type(MyStream) -> bytes
- nemo_microservices._streaming.is_stream_class_type(
- typ: type,
TypeGuard for determining whether or not the given type is a subclass of
Stream
/AsyncStream