connection_utils
drunc.grpc_testing_tools.connection_utils
Functions
wait_for(condition, expected_value, timeout=10.0, poll_interval=0.1)
Wait for a condition to return an expected value within a timeout period.
Repeatedly evaluates the condition callable until it returns the expected value or the timeout is reached. Useful for polling operations in tests and async workflows.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
condition
|
Callable[[], Any]
|
Callable that returns a value to check. Should take no arguments. |
required |
expected_value
|
Any
|
The value to wait for. If None, waits for any truthy value. Can also be a tuple of acceptable values. |
required |
timeout
|
float
|
Maximum time to wait in seconds before raising TimeoutError. |
10.0
|
poll_interval
|
float
|
Time in seconds between condition evaluations. |
0.1
|
Returns:
| Type | Description |
|---|---|
Optional[Any]
|
The value returned by condition when it matches expected_value. |
Raises:
| Type | Description |
|---|---|
TimeoutError
|
If the condition doesn't return expected_value within timeout. |