mirror of
https://github.com/dragonpilot/dragonpilot.git
synced 2026-06-20 21:42:05 +08:00
casync: reuse requests session in RemoteChunkReader (#25045)
This commit is contained in:
@@ -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 @@ class RemoteChunkReader(ChunkReader):
|
||||
|
||||
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:
|
||||
|
||||
Reference in New Issue
Block a user