Wait until the server is up. Exit if it doesn't happen within the timeout.
(status_file: str, timeout: float = 5.0)
| 354 | |
| 355 | |
| 356 | def wait_for_server(status_file: str, timeout: float = 5.0) -> None: |
| 357 | """Wait until the server is up. |
| 358 | |
| 359 | Exit if it doesn't happen within the timeout. |
| 360 | """ |
| 361 | endtime = time.time() + timeout |
| 362 | while time.time() < endtime: |
| 363 | try: |
| 364 | data = read_status(status_file) |
| 365 | except BadStatus: |
| 366 | # If the file isn't there yet, retry later. |
| 367 | time.sleep(0.1) |
| 368 | continue |
| 369 | # If the file's content is bogus or the process is dead, fail. |
| 370 | check_status(data) |
| 371 | print("Daemon started") |
| 372 | return |
| 373 | fail("Timed out waiting for daemon to start") |
| 374 | |
| 375 | |
| 376 | @action(run_parser) |
no test coverage detected
searching dependent graphs…