Make requests to provided url until it responds without error.
(url: str, timeout: float = 10.0, check_interval: float = 0.5)
| 15 | |
| 16 | |
| 17 | def wait_for_server_ready(url: str, timeout: float = 10.0, check_interval: float = 0.5) -> bool: |
| 18 | """Make requests to provided url until it responds without error.""" |
| 19 | conn_error = None |
| 20 | for _ in range(int(timeout / check_interval)): |
| 21 | try: |
| 22 | requests.get(url) |
| 23 | except requests.ConnectionError as exc: |
| 24 | time.sleep(check_interval) |
| 25 | conn_error = str(exc) |
| 26 | else: |
| 27 | return True |
| 28 | raise RuntimeError(conn_error) |
| 29 | |
| 30 | |
| 31 | @pytest.fixture(scope="session") |