diff options
author | Zac Medico <zmedico@gentoo.org> | 2020-02-17 10:32:06 -0800 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2020-02-17 14:29:09 -0800 |
commit | d66e9ec0b10522528d62e18b83e012c1ec121787 (patch) | |
tree | cfeef6845f701c23c44fabc773a8e884cc477568 /lib/portage/tests/util/futures | |
parent | fetch: remove secpass import (bug 601252) (diff) | |
download | portage-d66e9ec0b10522528d62e18b83e012c1ec121787.tar.gz portage-d66e9ec0b10522528d62e18b83e012c1ec121787.tar.bz2 portage-d66e9ec0b10522528d62e18b83e012c1ec121787.zip |
AsynchronousTask: add coroutine async_start method
Add coroutine async_start coroutine method which calls an _async_start
template method. Eventually, subclasses having _start implementations
that need to write to a build log will be required to implement an
_async_start coroutine method to replace the _start method as
discussed in bug 709746.
Bug: https://bugs.gentoo.org/709746
Signed-off-by: Zac Medico <zmedico@gentoo.org>
Diffstat (limited to 'lib/portage/tests/util/futures')
-rw-r--r-- | lib/portage/tests/util/futures/test_iter_completed.py | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/lib/portage/tests/util/futures/test_iter_completed.py b/lib/portage/tests/util/futures/test_iter_completed.py index 9ab410a9e..aa24f5685 100644 --- a/lib/portage/tests/util/futures/test_iter_completed.py +++ b/lib/portage/tests/util/futures/test_iter_completed.py @@ -1,4 +1,4 @@ -# Copyright 2018 Gentoo Foundation +# Copyright 2018-2020 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 import time @@ -6,6 +6,7 @@ from portage.tests import TestCase from portage.util._async.ForkProcess import ForkProcess from portage.util._eventloop.global_event_loop import global_event_loop from portage.util.futures import asyncio +from portage.util.futures.compat_coroutine import coroutine, coroutine_return from portage.util.futures.iter_completed import ( iter_completed, async_iter_completed, @@ -43,12 +44,17 @@ class IterCompletedTestCase(TestCase): expected_order = sorted(task.seconds for task in tasks) + @coroutine + def task_coroutine(task): + task.future = loop.create_future() + task.scheduler = loop + yield task.async_start() + result = yield task.future + coroutine_return(result) + def future_generator(): for task in tasks: - task.future = loop.create_future() - task.scheduler = loop - task.start() - yield task.future + yield task_coroutine(task) for seconds, future in zip(expected_order, iter_completed(future_generator(), max_jobs=True, max_load=None, loop=loop)): |