From 7b441aa0fd87f808ae04e29ad5876df7d580509e Mon Sep 17 00:00:00 2001 From: discountchubbs Date: Thu, 13 Aug 2026 22:11:09 -0700 Subject: [PATCH] transition to requests --- openpilot/sunnypilot/models/manager.py | 32 +++++++++++++------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/openpilot/sunnypilot/models/manager.py b/openpilot/sunnypilot/models/manager.py index d742e968a9..297866ccdf 100644 --- a/openpilot/sunnypilot/models/manager.py +++ b/openpilot/sunnypilot/models/manager.py @@ -9,7 +9,7 @@ import asyncio import os import time -import aiohttp +import requests from openpilot.common.params import Params from openpilot.common.realtime import Ratekeeper from openpilot.common.swaglog import cloudlog @@ -63,14 +63,14 @@ class ModelManagerSP: """Downloads a file with progress tracking""" self._download_start_times[model.fileName] = time.monotonic() - async with aiohttp.ClientSession() as session: - async with session.get(url) as response: - response.raise_for_status() - total_size = int(response.headers.get("content-length", 0)) - bytes_downloaded = 0 + with requests.get(url, stream=True, timeout=30) as response: # noqa: ASYNC210 + response.raise_for_status() + total_size = int(response.headers.get("content-length", 0)) + bytes_downloaded = 0 - with open(path, 'wb') as f: # noqa: ASYNC230 - async for chunk in response.content.iter_chunked(self._chunk_size): # type: bytes + with open(path, 'wb') as f: # noqa: ASYNC230 + for chunk in response.iter_content(chunk_size=self._chunk_size): + if chunk: f.write(chunk) bytes_downloaded += len(chunk) @@ -85,8 +85,8 @@ class ModelManagerSP: self._sync_artifact_progress(model) self._report_status() - # Clean up start time after download completes - del self._download_start_times[model.fileName] + # Clean up start time after download completes + del self._download_start_times[model.fileName] async def _download_chunked(self, base_url: str, base_path: str, artifact) -> None: from openpilot.common.file_chunker import get_chunk_name, get_manifest_path @@ -102,12 +102,12 @@ class ModelManagerSP: chunk_url = get_chunk_name(base_url, i, num_chunks) chunk_path = get_chunk_name(base_path, i, num_chunks) chunk_downloaded = 0 - async with aiohttp.ClientSession() as session: - async with session.get(chunk_url) as response: - response.raise_for_status() - chunk_size = int(response.headers.get("content-length", 0)) - with open(chunk_path, 'wb') as f: # noqa: ASYNC230 - async for data in response.content.iter_chunked(self._chunk_size): + with requests.get(chunk_url, stream=True, timeout=30) as response: # noqa: ASYNC210 + response.raise_for_status() + chunk_size = int(response.headers.get("content-length", 0)) + with open(chunk_path, 'wb') as f: # noqa: ASYNC230 + for data in response.iter_content(chunk_size=self._chunk_size): + if data: f.write(data) chunk_downloaded += len(data) if self.params.get("ModelManager_DownloadIndex") is None: