(_: FastAPI)
| 132 | |
| 133 | @asynccontextmanager |
| 134 | async def lifespan(_: FastAPI) -> AsyncIterator[None]: |
| 135 | _background_tasks = set() |
| 136 | t = asyncio.create_task(_sweep_loop()) |
| 137 | _background_tasks.add(t) |
| 138 | t.add_done_callback(_background_tasks.discard) |
| 139 | if os.environ.get("STEMDECK_DESKTOP") == "1": |
| 140 | parent_pid = os.environ.get("STEMDECK_PARENT_PID") |
| 141 | if parent_pid: |
| 142 | try: |
| 143 | parent_pid_int = int(parent_pid) |
| 144 | except ValueError: |
| 145 | _log.warning("invalid STEMDECK_PARENT_PID=%r", parent_pid) |
| 146 | else: |
| 147 | if parent_pid_int > 0 and parent_pid_int != os.getpid(): |
| 148 | wt = asyncio.create_task(_desktop_parent_watchdog(parent_pid_int)) |
| 149 | _background_tasks.add(wt) |
| 150 | wt.add_done_callback(_background_tasks.discard) |
| 151 | yield |
| 152 | |
| 153 | |
| 154 | # Phones hitting the self-hosted server URL get the mobile UI; everything |
nothing calls this directly
no test coverage detected