Parses a timeout string like '30s', '5m' into seconds.
(timeout_str: str)
| 532 | |
| 533 | |
| 534 | def _parse_timeout(timeout_str: str) -> float: |
| 535 | """Parses a timeout string like '30s', '5m' into seconds.""" |
| 536 | match = re.match(r'^(\d+)([sm])?$', timeout_str) |
| 537 | if not match: |
| 538 | raise ValueError(f'Invalid timeout format: {timeout_str}') |
| 539 | val, unit = match.groups() |
| 540 | seconds = float(val) |
| 541 | if unit == 'm': |
| 542 | seconds *= 60 |
| 543 | return seconds |
| 544 | |
| 545 | |
| 546 | async def run_once_cli( |
no test coverage detected