From: Zac Medico Date: Tue, 9 Jul 2013 21:20:05 +0000 (-0700) Subject: _job_delay: prevent accumlation of timeouts X-Git-Tag: v2.2.0_alpha188 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=0feda7b9d411ea972ec49b55da818b73cc9fd800;p=portage.git _job_delay: prevent accumlation of timeouts --- 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