Wait until a Cluster is gone
Parameters:
-
identifier
(ClusterId)
–
The ID of the cluster 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/async_dsql.py
| async def wait_until_cluster_not_exists(
self,
identifier: "capo_dsql.types.cluster_id.ClusterId",
*,
max_wait_time: float,
min_delay: float = 2,
max_delay: float = 120,
config_overrides: Optional[AsyncDSQLClientConfig] = None,
) -> ServiceError:
"""Wait until a Cluster is gone
Args:
identifier: <p>The ID of the cluster 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_cluster_output.GetClusterOutput | None" = (
None
)
op_error: ServiceError | None = None
try:
op_output = await self.get_cluster( # noqa: F841
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("cluster_not_exists", max_wait_time)
delay = min(max_delay, min_delay * (2**attempt))
delay = random.uniform(min_delay, delay)
delay = min(delay, remaining)
await anysleep(delay)
attempt += 1
|