mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-07-05 21:42:05 +08:00
mici setup: match tici network timeout
This commit is contained in:
@@ -51,11 +51,10 @@ exec ./launch_openpilot.sh
|
||||
|
||||
|
||||
class NetworkConnectivityMonitor:
|
||||
def __init__(self, should_check: Callable[[], bool] | None = None, check_interval: float = 1.0):
|
||||
def __init__(self, should_check: Callable[[], bool] | None = None):
|
||||
self.network_connected = threading.Event()
|
||||
self.wifi_connected = threading.Event()
|
||||
self._should_check = should_check or (lambda: True)
|
||||
self._check_interval = check_interval
|
||||
self._stop_event = threading.Event()
|
||||
self._thread: threading.Thread | None = None
|
||||
|
||||
@@ -80,7 +79,7 @@ class NetworkConnectivityMonitor:
|
||||
if self._should_check():
|
||||
try:
|
||||
request = urllib.request.Request(OPENPILOT_URL, method="HEAD")
|
||||
urllib.request.urlopen(request, timeout=1.0)
|
||||
urllib.request.urlopen(request, timeout=2.0)
|
||||
self.network_connected.set()
|
||||
if HARDWARE.get_network_type() == NetworkType.wifi:
|
||||
self.wifi_connected.set()
|
||||
@@ -89,7 +88,7 @@ class NetworkConnectivityMonitor:
|
||||
else:
|
||||
self.reset()
|
||||
|
||||
if self._stop_event.wait(timeout=self._check_interval):
|
||||
if self._stop_event.wait(timeout=1.0):
|
||||
break
|
||||
|
||||
|
||||
|
||||
@@ -218,7 +218,7 @@ class Setup(Widget):
|
||||
while not self.stop_network_check_thread.is_set():
|
||||
if self.state == SetupState.NETWORK_SETUP:
|
||||
try:
|
||||
urllib.request.urlopen(OPENPILOT_URL, timeout=2)
|
||||
urllib.request.urlopen(OPENPILOT_URL, timeout=2.0)
|
||||
self.network_connected.set()
|
||||
if HARDWARE.get_network_type() == NetworkType.wifi:
|
||||
self.wifi_connected.set()
|
||||
@@ -226,7 +226,7 @@ class Setup(Widget):
|
||||
self.wifi_connected.clear()
|
||||
except Exception:
|
||||
self.network_connected.clear()
|
||||
time.sleep(1)
|
||||
time.sleep(1.0)
|
||||
|
||||
def start_network_check(self):
|
||||
if self.network_check_thread is None or not self.network_check_thread.is_alive():
|
||||
|
||||
Reference in New Issue
Block a user