Skip to content

wait_until_stream_not_exists

wait_until_stream_not_exists(
    cluster_identifier: ClusterId,
    stream_identifier: StreamId,
    *,
    max_wait_time: float,
    min_delay: float = 2,
    max_delay: float = 120,
    config_overrides: Optional[DSQLClientConfig] = None,
) -> ServiceError

Wait until a Stream is gone

Parameters:

  • cluster_identifier (ClusterId) –

    The ID of the cluster containing the stream to retrieve.

  • stream_identifier (StreamId) –

    The ID of the stream to retrieve.

  • max_wait_time (float) –

    Maximum total seconds to wait before raising WaiterTimeoutError.

  • min_delay (float, default: 2 ) –

    Minimum seconds between operation attempts (spec default 2).

  • max_delay (float, default: 120 ) –

    Maximum seconds between operation attempts (spec default 120).

Source code in docs_src/capo_dsql/_services/dsql.py
def wait_until_stream_not_exists(
    self,
    cluster_identifier: "capo_dsql.types.cluster_id.ClusterId",
    stream_identifier: "capo_dsql.types.stream_id.StreamId",
    *,
    max_wait_time: float,
    min_delay: float = 2,
    max_delay: float = 120,
    config_overrides: Optional[DSQLClientConfig] = None,
) -> ServiceError:
    """Wait until a Stream is gone

    Args:
        cluster_identifier: <p>The ID of the cluster containing the stream to retrieve.</p>
        stream_identifier: <p>The ID of the stream to retrieve.</p>
        max_wait_time: Maximum total seconds to wait before raising WaiterTimeoutError.
        min_delay: Minimum seconds between operation attempts (spec default 2).
        max_delay: Maximum seconds between operation attempts (spec default 120).
    """
    start = time.monotonic()
    attempt = 0
    while True:
        op_output: "capo_dsql.types.get_stream_output.GetStreamOutput | None" = None
        op_error: ServiceError | None = None
        try:
            op_output = self.get_stream(  # noqa: F841
                cluster_identifier,
                stream_identifier,
                config_overrides=config_overrides,
            )
        except ServiceError as e:
            op_error = e
        if op_error is not None and op_error.code == "ResourceNotFoundException":
            return op_error
        elif op_error is not None:
            raise op_error

        elapsed = time.monotonic() - start
        remaining = max_wait_time - elapsed
        if remaining <= 0:
            raise WaiterTimeoutError("stream_not_exists", max_wait_time)
        delay = min(max_delay, min_delay * (2**attempt))
        delay = random.uniform(min_delay, delay)
        delay = min(delay, remaining)
        time.sleep(delay)
        attempt += 1