[downloader:http] handle exceptions while consuming content

This commit is contained in:
ClosedPort22
2023-03-11 21:36:37 +08:00
parent df77271438
commit fcaeaf539c
2 changed files with 10 additions and 3 deletions

View File

@@ -296,8 +296,15 @@ class HttpDownloader(DownloaderBase):
def release_conn(self, response):
"""Release connection back to pool by consuming response body"""
for _ in response.iter_content(self.chunk_size):
pass
try:
for _ in response.iter_content(self.chunk_size):
pass
except (RequestException, SSLError, OpenSSLError) as exc:
print()
self.log.debug(
"Unable to consume response body (%s); "
"closing the connection anyway", exc)
response.close()
@staticmethod
def receive(fp, content, bytes_total, bytes_start):