aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2020-04-07 22:13:17 -0700
committerZac Medico <zmedico@gentoo.org>2020-04-07 22:29:49 -0700
commit71ae5a58fe72bc32dce030210a73ea5c9eeb4a1c (patch)
tree4b26689841ad20eb5231f1fbfe82732fb7fbaf13 /lib/_emerge
parentRevert "AbstractEbuildProcess: add _async_start coroutine" (diff)
downloadportage-71ae5a58fe72bc32dce030210a73ea5c9eeb4a1c.tar.gz
portage-71ae5a58fe72bc32dce030210a73ea5c9eeb4a1c.tar.bz2
portage-71ae5a58fe72bc32dce030210a73ea5c9eeb4a1c.zip
Revert "AsynchronousTask: add coroutine async_start method"
This reverts commit d66e9ec0b10522528d62e18b83e012c1ec121787. Bug: https://bugs.gentoo.org/716636 Signed-off-by: Zac Medico <zmedico@gentoo.org>
Diffstat (limited to 'lib/_emerge')
-rw-r--r--lib/_emerge/AsynchronousTask.py22
-rw-r--r--lib/_emerge/CompositeTask.py17
-rw-r--r--lib/_emerge/TaskSequence.py7
3 files changed, 9 insertions, 37 deletions
diff --git a/lib/_emerge/AsynchronousTask.py b/lib/_emerge/AsynchronousTask.py
index b25a146c7..28beb4992 100644
--- a/lib/_emerge/AsynchronousTask.py
+++ b/lib/_emerge/AsynchronousTask.py
@@ -1,11 +1,10 @@
-# Copyright 1999-2020 Gentoo Authors
+# Copyright 1999-2018 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
import signal
from portage import os
from portage.util.futures import asyncio
-from portage.util.futures.compat_coroutine import coroutine, coroutine_return
from portage.util.SlotObject import SlotObject
class AsynchronousTask(SlotObject):
@@ -23,17 +22,6 @@ class AsynchronousTask(SlotObject):
_cancelled_returncode = - signal.SIGINT
- @coroutine
- def async_start(self):
- self._start_hook()
- yield self._async_start()
-
- @coroutine
- def _async_start(self):
- self._start()
- coroutine_return()
- yield None
-
def start(self):
"""
Start an asynchronous task and then return as soon as possible.
@@ -41,10 +29,6 @@ class AsynchronousTask(SlotObject):
self._start_hook()
self._start()
- def _start(self):
- self.returncode = os.EX_OK
- self._async_wait()
-
def async_wait(self):
"""
Wait for returncode asynchronously. Notification is available
@@ -65,6 +49,10 @@ class AsynchronousTask(SlotObject):
self._async_wait()
return waiter
+ def _start(self):
+ self.returncode = os.EX_OK
+ self._async_wait()
+
def isAlive(self):
return self.returncode is None
diff --git a/lib/_emerge/CompositeTask.py b/lib/_emerge/CompositeTask.py
index 21129758a..72da6fac1 100644
--- a/lib/_emerge/CompositeTask.py
+++ b/lib/_emerge/CompositeTask.py
@@ -1,10 +1,8 @@
-# Copyright 1999-2020 Gentoo Authors
+# Copyright 1999-2018 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
from _emerge.AsynchronousTask import AsynchronousTask
from portage import os
-from portage.util.futures import asyncio
-
class CompositeTask(AsynchronousTask):
@@ -100,7 +98,7 @@ class CompositeTask(AsynchronousTask):
def _start_task(self, task, exit_handler):
"""
Register exit handler for the given task, set it
- as self._current_task, and call task.async_start().
+ as self._current_task, and call task.start().
Subclasses can use this as a generic way to start
a task.
@@ -112,16 +110,7 @@ class CompositeTask(AsynchronousTask):
pass
task.addExitListener(exit_handler)
self._current_task = task
- result = asyncio.ensure_future(task.async_start(), loop=self.scheduler)
- result.add_done_callback(self._current_task_start_cb)
-
- def _current_task_start_cb(self, future):
- try:
- future.result()
- except asyncio.CancelledError:
- self.cancelled = True
- self._was_cancelled()
- self._async_wait()
+ task.start()
def _task_queued(self, task):
task.addStartListener(self._task_queued_start_handler)
diff --git a/lib/_emerge/TaskSequence.py b/lib/_emerge/TaskSequence.py
index 59ee5686d..1f2ba94c2 100644
--- a/lib/_emerge/TaskSequence.py
+++ b/lib/_emerge/TaskSequence.py
@@ -1,4 +1,4 @@
-# Copyright 1999-2020 Gentoo Authors
+# Copyright 1999-2014 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
import sys
@@ -42,11 +42,6 @@ class TaskSequence(CompositeTask):
self._start_task(task, self._task_exit_handler)
- def _current_task_start_cb(self, future):
- CompositeTask._current_task_start_cb(self, future)
- if self.cancelled:
- self._task_queue.clear()
-
def _task_exit_handler(self, task):
if self._default_exit(task) != os.EX_OK:
self.wait()