| |
@@ -47,17 +47,21 @@
|
| |
:param str path: Path to store the file to.
|
| |
:param str url: URL of file to download.
|
| |
:rtype: str
|
| |
- :return: content of downloaded file.
|
| |
+ :return: path to the downloaded file
|
| |
"""
|
| |
log.info("%r: Downloading %s", self.compose, url)
|
| |
- r = requests.get(url)
|
| |
+ r = requests.get(url, timeout=conf.net_timeout, stream=True)
|
| |
r.raise_for_status()
|
| |
|
| |
filename = os.path.basename(url)
|
| |
makedirs(os.path.join(path, "repodata"))
|
| |
- with open(os.path.join(path, "repodata", filename), "wb") as f:
|
| |
- f.write(r.content)
|
| |
- return r.content
|
| |
+ outfile = os.path.join(path, "repodata", filename)
|
| |
+ with open(outfile, "wb") as f:
|
| |
+ for chunk in r.iter_content(chunk_size=None):
|
| |
+ f.write(chunk)
|
| |
+ response_len = os.stat(outfile).st_size
|
| |
+ log.info("%r: Downloaded %d bytes from %s", self.compose, response_len, url)
|
| |
+ return outfile
|
| |
|
| |
def _download_repodata(self, path, baseurl):
|
| |
"""
|
| |
@@ -77,7 +81,9 @@
|
| |
|
| |
# Download the repomd.xml.
|
| |
repomd_url = os.path.join(baseurl, "repodata", "repomd.xml")
|
| |
- repomd = self._download_file(path, repomd_url)
|
| |
+ repomd_path = self._download_file(path, repomd_url)
|
| |
+ with open(repomd_path) as f:
|
| |
+ repomd = f.read()
|
| |
tree = ElementTree.fromstring(repomd)
|
| |
|
| |
# In case the repomd.xml did not change since the last compose, use
|
| |
Is
timeout
working the way you expect here? I've just briefly checked the documentation and it seems it defines the timeout for first response from the server. So if server is sending data 1KB/s, the timeout won't be reached, because it will really send some data during the conf.net_timeout.I think what you need is timeout for the complete response, not just for first bytes received.