PollScheduler: remove self._jobs
authorZac Medico <zmedico@gentoo.org>
Sat, 6 Oct 2012 04:00:19 +0000 (21:00 -0700)
committerZac Medico <zmedico@gentoo.org>
Sat, 6 Oct 2012 04:00:19 +0000 (21:00 -0700)
This is variable is only needed by the Scheduler class.

pym/_emerge/MetadataRegen.py
pym/_emerge/PollScheduler.py
pym/_emerge/Scheduler.py

index 234298f7ead6203ba07ee8e4dd6f027cd2952fe2..46b028a2765891bb3d97b70f2a2dc3e068f70cb9 100644 (file)
@@ -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
index bcf80ab5a8bb32fa77e84a48c45f6fb7b446abb1..1185cd726a2e78ecffb966ab16f81cbce7e9da54 100644 (file)
@@ -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:
index 795f503299b5b034b2129b2fdc100217fd6f3501..6a87938744d763e3c661e551e89209c21319cf29 100644 (file)
@@ -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: