[Yum-devel] [PATCH 3/4] pkglist: use streaming-friendly pkg split
Zdeněk Pavlas
zpavlas at redhat.com
Fri Nov 23 15:28:18 UTC 2012
---
createrepo/__init__.py | 6 ++++--
createrepo/utils.py | 15 ---------------
2 files changed, 4 insertions(+), 17 deletions(-)
diff --git a/createrepo/__init__.py b/createrepo/__init__.py
index 622e442..0f1cfee 100644
--- a/createrepo/__init__.py
+++ b/createrepo/__init__.py
@@ -47,7 +47,7 @@ except ImportError:
pass
from utils import _gzipOpen, compressFile, compressOpen, checkAndMakeDir, GzipFile, \
- checksum_and_rename, split_list_into_equal_chunks
+ checksum_and_rename
from utils import num_cpus_online
import deltarpms
@@ -612,7 +612,9 @@ class MetaDataGenerator:
self._worker_tmp_path = tempfile.mkdtemp() # setting this in the base object so we can clean it up later
if self.conf.workers < 1:
self.conf.workers = num_cpus_online()
- worker_chunks = split_list_into_equal_chunks(pkgfiles, self.conf.workers)
+ worker_chunks = [[] for i in range(self.conf.workers)]
+ for i, pkg in enumerate(pkgfiles):
+ worker_chunks[i % self.conf.workers].append(pkg)
worker_cmd_dict = {}
worker_jobs = {}
base_worker_cmdline = [self.conf.worker_cmd,
diff --git a/createrepo/utils.py b/createrepo/utils.py
index cfe68e6..af9f741 100644
--- a/createrepo/utils.py
+++ b/createrepo/utils.py
@@ -190,21 +190,6 @@ def encodefiletypelist(filetypelist):
result += ftl[x]
return result
-def split_list_into_equal_chunks(seq, num_chunks):
- if num_chunks <= 1:
- return [seq[:]]
- avg = len(seq) / float(num_chunks)
- out = []
- last = 0.0
- # Due to floating point math, we do one less than the number of chunks
- # and then the rest. Eg. range(1,6), 9
- while len(out) < (num_chunks - 1):
- out.append(seq[int(last):int(last + avg)])
- last += avg
- out.append(seq[int(last):])
-
- return out
-
def num_cpus_online(unknown=1):
if not hasattr(os, "sysconf"):
return unknown
--
1.7.4.4
More information about the Yum-devel
mailing list