Block until the MDM-read child process exits; return stdout JSON or None.
(handle: PrefetchHandle, timeout: float = 2.0)
| 219 | |
| 220 | |
| 221 | def wait_and_read_mdm(handle: PrefetchHandle, timeout: float = 2.0) -> str | None: |
| 222 | """Block until the MDM-read child process exits; return stdout JSON or None.""" |
| 223 | if handle.process is None: |
| 224 | return None |
| 225 | try: |
| 226 | stdout, _stderr = handle.process.communicate(timeout=timeout) |
| 227 | except subprocess.TimeoutExpired: |
| 228 | handle.process.kill() |
| 229 | return None |
| 230 | if handle.process.returncode != 0: |
| 231 | return None |
| 232 | text = stdout.decode("utf-8", errors="replace").strip() |
| 233 | return text or None |
| 234 | |
| 235 | |
| 236 | def start_project_scan(root: Path) -> PrefetchHandle: |