diff options
author | Zac Medico <zmedico@gentoo.org> | 2013-07-09 14:20:05 -0700 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2013-07-09 14:20:05 -0700 |
commit | 0feda7b9d411ea972ec49b55da818b73cc9fd800 (patch) | |
tree | e7610663228cf7a2a12bfd40548ee1b64b74ca8b | |
parent | Delay for loadavg after SIGCONT, bug #476104 (diff) | |
download | portage-0feda7b9d411ea972ec49b55da818b73cc9fd800.tar.gz portage-0feda7b9d411ea972ec49b55da818b73cc9fd800.tar.bz2 portage-0feda7b9d411ea972ec49b55da818b73cc9fd800.zip |
_job_delay: prevent accumlation of timeoutsv2.2.0_alpha188
-rw-r--r-- | pym/_emerge/Scheduler.py | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/pym/_emerge/Scheduler.py b/pym/_emerge/Scheduler.py index 5cb4128b3..d663e972f 100644 --- a/pym/_emerge/Scheduler.py +++ b/pym/_emerge/Scheduler.py @@ -250,6 +250,7 @@ class Scheduler(PollScheduler): # new jobs. self._job_delay_max = 5 self._previous_job_start_time = None + self._job_delay_timeout_id = None # The load average takes some time to respond when after # a SIGSTOP/SIGCONT cycle, so delay scheduling for some @@ -1610,7 +1611,12 @@ class Scheduler(PollScheduler): # elapsed_seconds < 0 means the system clock has been adjusted if elapsed_seconds > 0 and \ elapsed_seconds < self._sigcont_delay: - self._event_loop.timeout_add( + + if self._job_delay_timeout_id is not None: + self._event_loop.source_remove( + self._job_delay_timeout_id) + + self._job_delay_timeout_id = self._event_loop.timeout_add( 1000 * (self._sigcont_delay - elapsed_seconds), self._schedule_once) return True @@ -1631,7 +1637,12 @@ class Scheduler(PollScheduler): elapsed_seconds = current_time - self._previous_job_start_time # elapsed_seconds < 0 means the system clock has been adjusted if elapsed_seconds > 0 and elapsed_seconds < delay: - self._event_loop.timeout_add( + + if self._job_delay_timeout_id is not None: + self._event_loop.source_remove( + self._job_delay_timeout_id) + + self._job_delay_timeout_id = self._event_loop.timeout_add( 1000 * (delay - elapsed_seconds), self._schedule_once) return True |