Retry session.ping() until success or timeout.
(
session: DaprSession, timeout_seconds: float = 5.0, interval_seconds: float = 0.5
)
| 85 | |
| 86 | |
| 87 | async def ping_with_retry( |
| 88 | session: DaprSession, timeout_seconds: float = 5.0, interval_seconds: float = 0.5 |
| 89 | ) -> bool: |
| 90 | """Retry session.ping() until success or timeout.""" |
| 91 | now = asyncio.get_running_loop().time |
| 92 | deadline = now() + timeout_seconds |
| 93 | while True: |
| 94 | if await session.ping(): |
| 95 | return True |
| 96 | print("Dapr sidecar is not available! Retrying...") |
| 97 | if now() >= deadline: |
| 98 | return False |
| 99 | await asyncio.sleep(interval_seconds) |
| 100 | |
| 101 | |
| 102 | async def main(): |
no test coverage detected