From 57f8615f210e3ff2e0ce8e3183c73f7afc5ed0b1 Mon Sep 17 00:00:00 2001 From: Michael Hanselmann <hansmi@google.com> Date: Tue, 22 Jul 2008 14:05:08 +0000 Subject: [PATCH] Make argument to CleanCacheUnlocked mandatory Not passing the argument means it has the value None. Iterating None doesn't work: >>> "123" in None Traceback (most recent call last): File "<stdin>", line 1, in ? TypeError: iterable argument required Hence I rename it to "exclude" instead of "exceptions", which may be confusing, and make it mandatory. If one wants to clean all cache entries, an empty list can be passed. Reviewed-by: iustinp --- lib/jqueue.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/jqueue.py b/lib/jqueue.py index a5b2c85d4..e8a2bd525 100644 --- a/lib/jqueue.py +++ b/lib/jqueue.py @@ -436,18 +436,18 @@ class JobStorage(object): logging.debug("Writing job %s to %s", job.id, filename) utils.WriteFile(filename, data=serializer.DumpJson(job.Serialize(), indent=False)) - self._CleanCacheUnlocked(exceptions=[job.id]) + self._CleanCacheUnlocked([job.id]) - def _CleanCacheUnlocked(self, exceptions=None): + def _CleanCacheUnlocked(self, exclude): """Clean the memory cache. The exceptions argument contains job IDs that should not be cleaned. """ - assert isinstance(exceptions, list) + assert isinstance(exclude, list) for job in self._memcache.values(): - if job.id in exceptions: + if job.id in exclude: continue if job.GetStatus() not in (constants.JOB_STATUS_QUEUED, constants.JOB_STATUS_RUNNING): -- GitLab