def start(self):
assert not self.started, "File download has already been started, and cannot be started again"
# initialize the requests session, with backoff-retries enabled
self.session = requests.Session()
self.session.mount('http://', HTTPAdapter(max_retries=retries))
self.session.mount('https://', HTTPAdapter(max_retries=retries))
# initiate the download, check for status errors, and calculate download size
self.response = self.session.get(
self.source, stream=True, timeout=self.timeout)
self.response.raise_for_status()
self.total_size = int(self.response.headers['content-length'])
self.started = True
评论列表
文章目录