aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2016-08-20 06:06:38 -0700
committerZac Medico <zmedico@gentoo.org>2016-08-22 08:31:23 -0700
commitd54a795615ccb769a25a0f8d6cc15ba930ec428f (patch)
tree46fe76754da68954793ab37607103e6d84ea37e3
parentrepoman: fix _depend_checks baddepsyntax accounting (diff)
downloadportage-d54a795615ccb769a25a0f8d6cc15ba930ec428f.tar.gz
portage-d54a795615ccb769a25a0f8d6cc15ba930ec428f.tar.bz2
portage-d54a795615ccb769a25a0f8d6cc15ba930ec428f.zip
Scheduler._terminate_tasks: purge _running_tasks (bug 425554)
Fix the _terminate_tasks method to purge unstarted tasks from self._running_tasks, so that they don't keep the main loop running indefinitely. X-Gentoo-bug: 425554 X-Gentoo-bug-url: https://bugs.gentoo.org/show_bug.cgi?id=425554 Acked-by: Alexander Berntsen <bernalex@gentoo.org>
-rw-r--r--pym/_emerge/Scheduler.py15
1 files changed, 14 insertions, 1 deletions
diff --git a/pym/_emerge/Scheduler.py b/pym/_emerge/Scheduler.py
index 97b826a4d..71fe75f62 100644
--- a/pym/_emerge/Scheduler.py
+++ b/pym/_emerge/Scheduler.py
@@ -328,7 +328,20 @@ class Scheduler(PollScheduler):
def _terminate_tasks(self):
self._status_display.quiet = True
for task in list(self._running_tasks.values()):
- task.cancel()
+ if task.isAlive():
+ # This task should keep the main loop running until
+ # it has had an opportunity to clean up after itself.
+ # Rely on its exit hook to remove it from
+ # self._running_tasks when it has finished cleaning up.
+ task.cancel()
+ else:
+ # This task has been waiting to be started in one of
+ # self._task_queues which are all cleared below. It
+ # will never be started, so purged it from
+ # self._running_tasks so that it won't keep the main
+ # loop running.
+ del self._running_tasks[id(task)]
+
for q in self._task_queues.values():
q.clear()