aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2020-03-07 13:52:53 -0800
committerZac Medico <zmedico@gentoo.org>2020-03-07 14:01:22 -0800
commit8cc84cea654238676f7edc04b9c75c001535c0b4 (patch)
tree7699a0c1929cce4936e0a61c95b655402453c06c
parentAsynchronousTask: handle addStartListener after exit (bug 711322) (diff)
downloadportage-8cc84cea654238676f7edc04b9c75c001535c0b4.tar.gz
portage-8cc84cea654238676f7edc04b9c75c001535c0b4.tar.bz2
portage-8cc84cea654238676f7edc04b9c75c001535c0b4.zip
SequentialTaskQueue: cancel unstarted tasks when appropriate (bug 711322)
When the clear method is called, cancel any tasks which have not started yet, in order to ensure that their start/exit listeners are called. This fixes a case where emerge would hang after SIGINT. Also fix the CompositeTask _cancel method to react appropriately to the cancel event when the task has not started yet. Bug: https://bugs.gentoo.org/711322 Signed-off-by: Zac Medico <zmedico@gentoo.org>
-rw-r--r--lib/_emerge/CompositeTask.py4
-rw-r--r--lib/_emerge/SequentialTaskQueue.py3
2 files changed, 7 insertions, 0 deletions
diff --git a/lib/_emerge/CompositeTask.py b/lib/_emerge/CompositeTask.py
index 1d199d19b..2ad1d783d 100644
--- a/lib/_emerge/CompositeTask.py
+++ b/lib/_emerge/CompositeTask.py
@@ -20,6 +20,10 @@ class CompositeTask(AsynchronousTask):
self._async_wait()
else:
self._current_task.cancel()
+ elif self.returncode is None:
+ # Assume that the task has not started yet.
+ self._was_cancelled()
+ self._async_wait()
def _poll(self):
"""
diff --git a/lib/_emerge/SequentialTaskQueue.py b/lib/_emerge/SequentialTaskQueue.py
index 318bd6c55..38ebb98d8 100644
--- a/lib/_emerge/SequentialTaskQueue.py
+++ b/lib/_emerge/SequentialTaskQueue.py
@@ -74,7 +74,10 @@ class SequentialTaskQueue(SlotObject):
"""
Clear the task queue and asynchronously terminate any running tasks.
"""
+ for task in self._task_queue:
+ task.cancel()
self._task_queue.clear()
+
for task in list(self.running_tasks):
task.cancel()