From f135e0d3baec2d48ced22f53560f94bde5a563d3 Mon Sep 17 00:00:00 2001 From: Willem Melching Date: Wed, 6 Jul 2022 11:56:55 +0200 Subject: [PATCH] casync: reuse requests session in RemoteChunkReader --- 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: