From 2cc0eb1ca047f9fd94ad1f73ba14ea85753fde6e Mon Sep 17 00:00:00 2001 From: Adeeb <8762862+quillford@users.noreply.github.com> Date: Mon, 17 Feb 2020 10:37:38 -0800 Subject: [PATCH] update network type less frequently (#1108) --- selfdrive/thermald.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/selfdrive/thermald.py b/selfdrive/thermald.py index ad54d1e30a..648a82acde 100755 --- a/selfdrive/thermald.py +++ b/selfdrive/thermald.py @@ -192,10 +192,12 @@ def thermald_thread(): if health is not None: usb_power = health.health.usbPowerMode != log.HealthData.UsbPowerMode.client - try: - network_type = get_network_type() - except subprocess.CalledProcessError: - pass + # get_network_type is an expensive call. update every 3s + if (count % int(3. / DT_TRML)) == 0: + try: + network_type = get_network_type() + except subprocess.CalledProcessError: + pass msg.thermal.freeSpace = get_available_percent(default=100.0) / 100.0 msg.thermal.memUsedPercent = int(round(psutil.virtual_memory().percent))