module documentation

gRPC keepalive configuration shared by SDK channels.

Channel constructors accept keepalive as None/True for SDK defaults, False to disable SDK keepalive, or explicit KeepaliveOptions / mapping overrides. With the default None value the SDK reads NEBIUS_GRPC_KEEPALIVE_* environment variables. Explicit constructor options ignore those environment variables and use SDK defaults for omitted fields.

The resolved configuration is converted into Python gRPC channel arguments by keepalive_channel_options.

Class KeepaliveConfig Resolved keepalive configuration.
Class KeepaliveOptions Explicit keepalive overrides for nebius.aio.channel.Channel.
Function default_keepalive_config Return the GoSDK-compatible default keepalive configuration.
Function keepalive_channel_options Convert keepalive config to Python gRPC channel options.
Function keepalive_config_from_env Resolve keepalive configuration from environment variables.
Function keepalive_config_from_options Resolve keepalive configuration from explicit constructor options.
Function parse_go_bool Parse Go strconv.ParseBool accepted values.
Function parse_go_duration_ms Parse a subset of Go time.ParseDuration syntax into milliseconds.
Function validate_keepalive_config Validate resolved keepalive values.
Constant DEFAULT_KEEPALIVE_PERMIT_WITHOUT_STREAM Whether keepalive pings are sent without active RPC streams.
Constant DEFAULT_KEEPALIVE_TIME_MS Default interval between client keepalive pings, in milliseconds.
Constant DEFAULT_KEEPALIVE_TIMEOUT_MS Default timeout for a keepalive ping response, in milliseconds.
Constant ENV_GRPC_KEEPALIVE_PERMIT_WITHOUT_STREAM Undocumented
Constant ENV_GRPC_KEEPALIVE_TIME Undocumented
Constant ENV_GRPC_KEEPALIVE_TIMEOUT Undocumented
Function _assert_valid_keepalive_ms Undocumented
Function _duration_part_ns Undocumented
Function _lookup_keepalive_env Undocumented
Function _mapping_keepalive_bool Undocumented
Function _mapping_keepalive_int Undocumented
Constant _DURATION_PART_RE Undocumented
Constant _NANOSECONDS_IN_MILLISECOND Undocumented
Constant _UNIT_TO_NANOSECONDS Undocumented
def default_keepalive_config() -> KeepaliveConfig: (source)

Return the GoSDK-compatible default keepalive configuration.

def keepalive_channel_options(cfg: KeepaliveConfig) -> ChannelArgumentType: (source)

Convert keepalive config to Python gRPC channel options.

def keepalive_config_from_env(env: Mapping[str, str | None] | None = None) -> KeepaliveConfig: (source)

Resolve keepalive configuration from environment variables.

Durations use Go-style syntax such as 20s, 500ms, or 1m30s. Boolean values follow Go strconv.ParseBool accepted values.

def keepalive_config_from_options(options: KeepaliveOptions | Mapping[str, object] | bool | None) -> KeepaliveConfig: (source)

Resolve keepalive configuration from explicit constructor options.

None reads environment variables, True forces SDK defaults, and False disables SDK keepalive. Mappings accept both snake_case and camelCase keys: time_ms/timeMs, timeout_ms/timeoutMs, and permit_without_stream/permitWithoutStream.

def parse_go_bool(name: str, value: str) -> bool: (source)

Parse Go strconv.ParseBool accepted values.

def parse_go_duration_ms(name: str, value: str) -> int: (source)

Parse a subset of Go time.ParseDuration syntax into milliseconds.

def validate_keepalive_config(cfg: KeepaliveConfig): (source)

Validate resolved keepalive values.

DEFAULT_KEEPALIVE_PERMIT_WITHOUT_STREAM: bool = (source)

Whether keepalive pings are sent without active RPC streams.

Value
True
DEFAULT_KEEPALIVE_TIME_MS: int = (source)

Default interval between client keepalive pings, in milliseconds.

Value
20000
DEFAULT_KEEPALIVE_TIMEOUT_MS: int = (source)

Default timeout for a keepalive ping response, in milliseconds.

Value
10000
ENV_GRPC_KEEPALIVE_PERMIT_WITHOUT_STREAM: str = (source)

Undocumented

Value
'NEBIUS_GRPC_KEEPALIVE_PERMIT_WITHOUT_STREAM'
ENV_GRPC_KEEPALIVE_TIME: str = (source)

Undocumented

Value
'NEBIUS_GRPC_KEEPALIVE_TIME'
ENV_GRPC_KEEPALIVE_TIMEOUT: str = (source)

Undocumented

Value
'NEBIUS_GRPC_KEEPALIVE_TIMEOUT'
def _assert_valid_keepalive_ms(name: str, value: int, allow_zero: bool): (source)

Undocumented

def _duration_part_ns(match: Match[str]) -> Decimal: (source)

Undocumented

def _lookup_keepalive_env(env: Mapping[str, str | None], name: str) -> str | None: (source)

Undocumented

def _mapping_keepalive_bool(options: Mapping[str, object], snake_name: str, camel_name: str) -> bool | None: (source)

Undocumented

def _mapping_keepalive_int(options: Mapping[str, object], snake_name: str, camel_name: str) -> int | None: (source)

Undocumented

_DURATION_PART_RE = (source)

Undocumented

Value
compile('([0-9]+(?:\\.[0-9]*)?|\\.[0-9]+)(ns|us|µs|μs|ms|s|m|h)')
_NANOSECONDS_IN_MILLISECOND = (source)

Undocumented

Value
Decimal(1000000)
_UNIT_TO_NANOSECONDS = (source)

Undocumented

Value
{'ns': Decimal(1),
 'us': Decimal(1000),
 'µs': Decimal(1000),
 'μs': Decimal(1000),
 'ms': Decimal(1000000),
 's': Decimal(1000000000),
 'm': Decimal(60000000000),
...