From 50434d612ee7becc09aef762a6c8fb8d8111af6d Mon Sep 17 00:00:00 2001 From: Willem Melching Date: Wed, 6 Jul 2022 12:08:51 +0200 Subject: [PATCH] casync: reuse requests session in RemoteChunkReader (#25045) --- system/hardware/tici/casync.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/system/hardware/tici/casync.py b/system/hardware/tici/casync.py index b857c047952fde..d0d0da3c6a17a3 100755 --- a/system/hardware/tici/casync.py +++ b/system/hardware/tici/casync.py @@ -55,6 +55,7 @@ class RemoteChunkReader(ChunkReader): def __init__(self, url: str) -> None: super().__init__() self.url = url + self.session = requests.Session() def read(self, chunk: Chunk) -> bytes: sha_hex = chunk.sha.hex() @@ -62,7 +63,7 @@ def read(self, chunk: Chunk) -> bytes: for i in range(CHUNK_DOWNLOAD_RETRIES): try: - resp = requests.get(url, timeout=CHUNK_DOWNLOAD_TIMEOUT) + resp = self.session.get(url, timeout=CHUNK_DOWNLOAD_TIMEOUT) break except Exception: if i == CHUNK_DOWNLOAD_RETRIES - 1: