Gentoo Archives: gentoo-commits

From: Zac Medico <zmedico@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/portage:master commit in: lib/_emerge/
Date: Sat, 07 Mar 2020 22:18:15
Message-Id: 1583618482.8cc84cea654238676f7edc04b9c75c001535c0b4.zmedico@gentoo
1 commit: 8cc84cea654238676f7edc04b9c75c001535c0b4
2 Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
3 AuthorDate: Sat Mar 7 21:52:53 2020 +0000
4 Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
5 CommitDate: Sat Mar 7 22:01:22 2020 +0000
6 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=8cc84cea
7
8 SequentialTaskQueue: cancel unstarted tasks when appropriate (bug 711322)
9
10 When the clear method is called, cancel any tasks which have not
11 started yet, in order to ensure that their start/exit listeners are
12 called. This fixes a case where emerge would hang after SIGINT.
13
14 Also fix the CompositeTask _cancel method to react appropriately to
15 the cancel event when the task has not started yet.
16
17 Bug: https://bugs.gentoo.org/711322
18 Signed-off-by: Zac Medico <zmedico <AT> gentoo.org>
19
20 lib/_emerge/CompositeTask.py | 4 ++++
21 lib/_emerge/SequentialTaskQueue.py | 3 +++
22 2 files changed, 7 insertions(+)
23
24 diff --git a/lib/_emerge/CompositeTask.py b/lib/_emerge/CompositeTask.py
25 index 1d199d19b..2ad1d783d 100644
26 --- a/lib/_emerge/CompositeTask.py
27 +++ b/lib/_emerge/CompositeTask.py
28 @@ -20,6 +20,10 @@ class CompositeTask(AsynchronousTask):
29 self._async_wait()
30 else:
31 self._current_task.cancel()
32 + elif self.returncode is None:
33 + # Assume that the task has not started yet.
34 + self._was_cancelled()
35 + self._async_wait()
36
37 def _poll(self):
38 """
39
40 diff --git a/lib/_emerge/SequentialTaskQueue.py b/lib/_emerge/SequentialTaskQueue.py
41 index 318bd6c55..38ebb98d8 100644
42 --- a/lib/_emerge/SequentialTaskQueue.py
43 +++ b/lib/_emerge/SequentialTaskQueue.py
44 @@ -74,7 +74,10 @@ class SequentialTaskQueue(SlotObject):
45 """
46 Clear the task queue and asynchronously terminate any running tasks.
47 """
48 + for task in self._task_queue:
49 + task.cancel()
50 self._task_queue.clear()
51 +
52 for task in list(self.running_tasks):
53 task.cancel()