(binary, env, pid)
| 58 | |
| 59 | |
| 60 | def stop_daemon(binary, env, pid): |
| 61 | stopped = False |
| 62 | try: |
| 63 | subprocess.run([binary, "daemon", "stop"], capture_output=True, timeout=30, env=env) |
| 64 | except (OSError, subprocess.TimeoutExpired): |
| 65 | pass |
| 66 | deadline = time.monotonic() + 5 |
| 67 | while time.monotonic() < deadline: |
| 68 | try: |
| 69 | status = subprocess.run([binary, "daemon", "status"], capture_output=True, |
| 70 | timeout=2, env=env) |
| 71 | if status.returncode != 0 and "not running" in output_text(status): |
| 72 | stopped = True |
| 73 | break |
| 74 | except (OSError, subprocess.TimeoutExpired): |
| 75 | pass |
| 76 | time.sleep(0.1) |
| 77 | if not stopped: |
| 78 | force_kill(pid) |
| 79 | |
| 80 | |
| 81 | def occupied_loopback_port(): |
no test coverage detected