From dba3bc75399ce520de6eb96b0a93c829114580d9 Mon Sep 17 00:00:00 2001 From: Toshio Kuratomi Date: Wed, 24 Jun 2015 08:12:49 -0700 Subject: [PATCH] Read the url in in chunks so that we don't use as much memory for large packages --- packaging/os/yum.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/packaging/os/yum.py b/packaging/os/yum.py index 22e7ca4ad71..14339b4c18b 100644 --- a/packaging/os/yum.py +++ b/packaging/os/yum.py @@ -152,6 +152,9 @@ EXAMPLES = ''' yum: name="@Development tools" state=present ''' +# 64k. Number of bytes to read at a time when manually downloading pkgs via a url +BUFSIZE = 65536 + def_qf = "%{name}-%{version}-%{release}.%{arch}" def log(msg): @@ -526,9 +529,11 @@ def install(module, items, repoq, yum_basecmd, conf_file, en_repos, dis_repos): package = os.path.join(tempdir, str(pkg.rsplit('/', 1)[1])) try: rsp, info = fetch_url(module, pkg) - data = rsp.read() f = open(package, 'w') - f.write(data) + data = rsp.read(BUFSIZE) + while data: + f.write(data) + data = rsp.read(BUFSIZE) f.close() pkg = package except Exception, e: