1 |
Fix the _terminate_tasks method to purge unstarted tasks from |
2 |
self._running_tasks, so that they don't keep the main loop |
3 |
running indefinitely. |
4 |
|
5 |
X-Gentoo-bug: 425554 |
6 |
X-Gentoo-bug-url: https://bugs.gentoo.org/show_bug.cgi?id=425554 |
7 |
--- |
8 |
pym/_emerge/Scheduler.py | 15 ++++++++++++++- |
9 |
1 file changed, 14 insertions(+), 1 deletion(-) |
10 |
|
11 |
diff --git a/pym/_emerge/Scheduler.py b/pym/_emerge/Scheduler.py |
12 |
index 97b826a..71fe75f 100644 |
13 |
--- a/pym/_emerge/Scheduler.py |
14 |
+++ b/pym/_emerge/Scheduler.py |
15 |
@@ -328,7 +328,20 @@ class Scheduler(PollScheduler): |
16 |
def _terminate_tasks(self): |
17 |
self._status_display.quiet = True |
18 |
for task in list(self._running_tasks.values()): |
19 |
- task.cancel() |
20 |
+ if task.isAlive(): |
21 |
+ # This task should keep the main loop running until |
22 |
+ # it has had an opportunity to clean up after itself. |
23 |
+ # Rely on its exit hook to remove it from |
24 |
+ # self._running_tasks when it has finished cleaning up. |
25 |
+ task.cancel() |
26 |
+ else: |
27 |
+ # This task has been waiting to be started in one of |
28 |
+ # self._task_queues which are all cleared below. It |
29 |
+ # will never be started, so purged it from |
30 |
+ # self._running_tasks so that it won't keep the main |
31 |
+ # loop running. |
32 |
+ del self._running_tasks[id(task)] |
33 |
+ |
34 |
for q in self._task_queues.values(): |
35 |
q.clear() |
36 |
|
37 |
-- |
38 |
2.7.4 |