Check if the process is alive. Return (pid, connection_name) on success. Raise BadStatus if something's wrong.
(data: dict[str, Any])
| 697 | |
| 698 | |
| 699 | def check_status(data: dict[str, Any]) -> tuple[int, str]: |
| 700 | """Check if the process is alive. |
| 701 | |
| 702 | Return (pid, connection_name) on success. |
| 703 | |
| 704 | Raise BadStatus if something's wrong. |
| 705 | """ |
| 706 | if "pid" not in data: |
| 707 | raise BadStatus("Invalid status file (no pid field)") |
| 708 | pid = data["pid"] |
| 709 | if not isinstance(pid, int): |
| 710 | raise BadStatus("pid field is not an int") |
| 711 | if not alive(pid): |
| 712 | raise BadStatus("Daemon has died") |
| 713 | if "connection_name" not in data: |
| 714 | raise BadStatus("Invalid status file (no connection_name field)") |
| 715 | connection_name = data["connection_name"] |
| 716 | if not isinstance(connection_name, str): |
| 717 | raise BadStatus("connection_name field is not a string") |
| 718 | return pid, connection_name |
| 719 | |
| 720 | |
| 721 | def is_running(status_file: str) -> bool: |
no test coverage detected
searching dependent graphs…