test car models: fix random hanging
diff --git a/selfdrive/test/test_car_models.py b/selfdrive/test/test_car_models.py
index 7faf63d2cc8829..b3ff2a9e5ec747 100755
--- a/selfdrive/test/test_car_models.py
+++ b/selfdrive/test/test_car_models.py
@@ -38,20 +38,24 @@ def wait_for_sockets(socks, timeout=10.0):
         recvd.append(s)
   return recvd
 
-def get_route_logs(route_name):
-  for log_f in ["rlog.bz2", "fcamera.hevc"]:
-    log_path = os.path.join("/tmp", "%s--0--%s" % (route_name.replace("|", "_"), log_f))
+def get_route_log(route_name):
+  log_path = os.path.join("/tmp", "%s--0--%s" % (route_name.replace("|", "_"), "rlog.bz2"))
 
-    if not os.path.isfile(log_path):
-      log_url = "https://commadataci.blob.core.windows.net/openpilotci/%s/0/%s" % (route_name.replace("|", "/"), log_f)
-      r = requests.get(log_url)
+  if not os.path.isfile(log_path):
+    log_url = "https://commadataci.blob.core.windows.net/openpilotci/%s/0/%s" % (route_name.replace("|", "/"), "rlog.bz2")
 
-      if r.status_code == 200:
-        with open(log_path, "wb") as f:
-          f.write(r.content)
-      else:
-        print("failed to download test log %s" % route_name)
-        sys.exit(-1)
+    # if request fails, try again once and let it throw exception if fails again
+    try:
+      r = requests.get(log_url, timeout=15)
+    except:
+      r = requests.get(log_url, timeout=15)
+
+    if r.status_code == 200:
+      with open(log_path, "wb") as f:
+        f.write(r.content)
+    else:
+      print("failed to download test log %s" % route_name)
+      sys.exit(-1)
 
 routes = {
 
@@ -490,7 +494,9 @@ def get_route_logs(route_name):
   results = {}
   for route, checks in routes.items():
     if route not in non_public_routes:
-      get_route_logs(route)
+      print("GETTING ROUTE LOGS")
+      get_route_log(route)
+      print("DONE GETTING ROUTE LOGS")
     elif "UNLOGGER_PATH" not in os.environ:
       continue
 
@@ -512,7 +518,7 @@ def get_route_logs(route_name):
       unlogger_cmd = [os.path.join(BASEDIR, os.environ['UNLOGGER_PATH']), route]
     else:
       unlogger_cmd = [os.path.join(BASEDIR, 'tools/replay/unlogger.py'), route, '/tmp']
-    unlogger = subprocess.Popen(unlogger_cmd + ['--disable', 'frame,plan,pathPlan,liveLongitudinalMpc,radarState,controlsState,liveTracks,liveMpc,sendcan,carState,carControl,carEvents,carParams', '--no-interactive'], preexec_fn=os.setsid)
+    unlogger = subprocess.Popen(unlogger_cmd + ['--disable', 'frame,encodeIdx,plan,pathPlan,liveLongitudinalMpc,radarState,controlsState,liveTracks,liveMpc,sendcan,carState,carControl,carEvents,carParams', '--no-interactive'], preexec_fn=os.setsid)
 
     print("Check sockets")
     extra_socks = []
diff --git a/tools/replay/unlogger.py b/tools/replay/unlogger.py
index 8208df7a44bb19..2defe073603f0a 100755
--- a/tools/replay/unlogger.py
+++ b/tools/replay/unlogger.py
@@ -68,7 +68,7 @@ def run(self, commands_address, data_address, pub_types):
       while True:
         while poller.poll(0.) or route is None:
           cookie, cmd = commands_socket.recv_pyobj()
-          route = self._process_commands(cmd, route)
+          route = self._process_commands(cmd, route, pub_types)
 
         # **** get message ****
         self._read_logs(cookie, pub_types)
@@ -121,7 +121,7 @@ def _send_logs(self, data_socket):
       data_socket.send_pyobj((cookie, typ, msg.logMonoTime, route_time), flags=zmq.SNDMORE)
       data_socket.send(smsg.to_bytes(), copy=False)
 
-  def _process_commands(self, cmd, route):
+  def _process_commands(self, cmd, route, pub_types):
     seek_to = None
     if route is None or (isinstance(cmd, SetRoute) and route.name != cmd.name):
       seek_to = cmd.start_time
@@ -129,10 +129,11 @@ def _process_commands(self, cmd, route):
       self._lr = MultiLogIterator(route.log_paths(), wraparound=True)
       if self._frame_reader is not None:
         self._frame_reader.close()
-      # reset frames for a route
-      self._frame_id_lookup = {}
-      self._frame_reader = RouteFrameReader(
-        route.camera_paths(), None, self._frame_id_lookup, readahead=True)
+      if "frame" in pub_types or "encodeIdx" in pub_types:
+        # reset frames for a route
+        self._frame_id_lookup = {}
+        self._frame_reader = RouteFrameReader(
+          route.camera_paths(), None, self._frame_id_lookup, readahead=True)
 
     # always reset this on a seek
     if isinstance(cmd, SeekRelativeTime):

Running locally, I reproduced a similar failure to the one seen in CI recently. It would get stuck downloading the front camera video, which was unnecessary, and was probably only done to make unlogger happy. Not having to download those videos each time should speed up the test a bit. Also added a timeout to the request so it doesn't just wait forever.

Fixes #1043 