From 637bb91a9439d4bb7f391fe6e804b64592812fdd Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Fri, 5 Oct 2012 21:00:19 -0700 Subject: [PATCH] PollScheduler: remove self._jobs This is variable is only needed by the Scheduler class. --- pym/_emerge/MetadataRegen.py | 5 +++-- pym/_emerge/PollScheduler.py | 3 +-- pym/_emerge/Scheduler.py | 4 ++++ 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/pym/_emerge/MetadataRegen.py b/pym/_emerge/MetadataRegen.py index 234298f7e..46b028a27 100644 --- a/pym/_emerge/MetadataRegen.py +++ b/pym/_emerge/MetadataRegen.py @@ -91,6 +91,9 @@ class MetadataRegen(PollScheduler): def _keep_scheduling(self): return self._remaining_tasks and not self._terminated_tasks + def _running_job_count(self): + return len(self._running_tasks) + def run(self): portdb = self._portdb @@ -155,14 +158,12 @@ class MetadataRegen(PollScheduler): self._remaining_tasks = False return - self._jobs += 1 self._running_tasks.add(metadata_process) metadata_process.scheduler = self.sched_iface metadata_process.addExitListener(self._metadata_exit) metadata_process.start() def _metadata_exit(self, metadata_process): - self._jobs -= 1 self._running_tasks.discard(metadata_process) if metadata_process.returncode != os.EX_OK: self.returncode = 1 diff --git a/pym/_emerge/PollScheduler.py b/pym/_emerge/PollScheduler.py index bcf80ab5a..1185cd726 100644 --- a/pym/_emerge/PollScheduler.py +++ b/pym/_emerge/PollScheduler.py @@ -41,7 +41,6 @@ class PollScheduler(object): self._terminated_tasks = False self._max_jobs = 1 self._max_load = None - self._jobs = 0 self._scheduling = False self._background = False if event_loop is not None: @@ -184,7 +183,7 @@ class PollScheduler(object): return bool(self._running_job_count()) def _running_job_count(self): - return self._jobs + raise NotImplementedError(self) def _can_add_job(self): if self._terminated_tasks: diff --git a/pym/_emerge/Scheduler.py b/pym/_emerge/Scheduler.py index 795f50329..6a8793874 100644 --- a/pym/_emerge/Scheduler.py +++ b/pym/_emerge/Scheduler.py @@ -225,6 +225,7 @@ class Scheduler(PollScheduler): self._prefetchers = weakref.WeakValueDictionary() self._pkg_queue = [] + self._jobs = 0 self._running_tasks = {} self._completed_tasks = set() @@ -1498,6 +1499,9 @@ class Scheduler(PollScheduler): def _is_work_scheduled(self): return bool(self._running_tasks) + def _running_job_count(self): + return self._jobs + def _schedule_tasks(self): while True: -- 2.26.2