File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -100,7 +100,9 @@ async def run(self) -> BootResult:
100100 await self ._maybe_scan_qr (facts )
101101
102102 self .progress .step = "probing_hardware"
103- camera_device = resolve_camera_device (self .settings .hardware .camera , self .hal .camera_probe )
103+ camera_device = await asyncio .to_thread (
104+ resolve_camera_device , self .settings .hardware .camera , self .hal .camera_probe
105+ )
104106 await asyncio .to_thread (self ._probe_hardware , facts , camera_device )
105107
106108 self .progress .step = "updating_repos"
Original file line number Diff line number Diff line change 11import shutil
22import subprocess
3+ import time
34from pathlib import Path
45from typing import Callable
56
67from robot_orchestrator .config import CameraConfig , McuConfig
78from robot_orchestrator .hal .base import CameraProbe , UsbInventory
89
910UdevQueryT = Callable [[Path , str ], "str | None" ]
11+ CAMERA_RESOLVE_RETRY_ATTEMPTS = 5
12+ CAMERA_RESOLVE_RETRY_DELAY_S = 1.5
1013
1114
1215def resolve_chromium_bin (which : Callable [[str ], "str | None" ] = shutil .which ) -> str :
@@ -23,6 +26,16 @@ def resolve_camera_device(
2326) -> str | None :
2427 if config .device != "auto" :
2528 return config .device
29+ for attempt in range (CAMERA_RESOLVE_RETRY_ATTEMPTS ):
30+ if attempt > 0 :
31+ time .sleep (CAMERA_RESOLVE_RETRY_DELAY_S )
32+ device = _resolve_camera_device_once (config , probe , by_id_dir )
33+ if device is not None :
34+ return device
35+ return None
36+
37+
38+ def _resolve_camera_device_once (config : CameraConfig , probe : CameraProbe , by_id_dir : Path ) -> str | None :
2639 if not by_id_dir .exists ():
2740 return None
2841 for candidate in sorted (by_id_dir .glob ("*" )):
You can’t perform that action at this time.
0 commit comments