mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-07-02 03:52:11 +08:00
casync: reuse requests session in RemoteChunkReader (#25045)
old-commit-hash: 50434d612ee7becc09aef762a6c8fb8d8111af6d
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