Scheduler: cleanup timeout after _main_loop
authorZac Medico <zmedico@gentoo.org>
Fri, 10 Feb 2012 21:58:17 +0000 (13:58 -0800)
committerZac Medico <zmedico@gentoo.org>
Fri, 10 Feb 2012 21:58:17 +0000 (13:58 -0800)
The way we don't leave an leak a reference to the Scheduler instance
in the global EventLoop instance.

pym/_emerge/Scheduler.py

index 674a11e49eea29da0123fd64c734282337fba352..100d89d1cf0bddcb7195152e41a705ca7d3f3c36 100644 (file)
@@ -196,8 +196,6 @@ class Scheduler(PollScheduler):
 
                self._status_display = JobStatusDisplay(
                        xterm_titles=('notitles' not in settings.features))
-               self.sched_iface.timeout_add(self._max_display_latency,
-                       self._status_display.display)
                self._max_load = myopts.get("--load-average")
                max_jobs = myopts.get("--jobs")
                if max_jobs is None:
@@ -1354,6 +1352,8 @@ class Scheduler(PollScheduler):
                failed_pkgs = self._failed_pkgs
                portage.locks._quiet = self._background
                portage.elog.add_listener(self._elog_listener)
+               display_timeout_id = self.sched_iface.timeout_add(
+                       self._max_display_latency, self._status_display.display)
                rval = os.EX_OK
 
                try:
@@ -1362,6 +1362,7 @@ class Scheduler(PollScheduler):
                        self._main_loop_cleanup()
                        portage.locks._quiet = False
                        portage.elog.remove_listener(self._elog_listener)
+                       self.sched_iface.source_remove(display_timeout_id)
                        if failed_pkgs:
                                rval = failed_pkgs[-1].returncode