diff options
author | Zac Medico <zmedico@gentoo.org> | 2020-02-23 13:44:58 -0800 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2020-02-23 18:35:15 -0800 |
commit | 4df7a0a0c16c5ded65ad601d39840797b7704770 (patch) | |
tree | 6e724cf5dc3b445f44aa2cae6354d113ae5b0e01 /lib/_emerge/AsynchronousTask.py | |
parent | EbuildBuildDir: use async_start method (diff) | |
download | portage-4df7a0a0c16c5ded65ad601d39840797b7704770.tar.gz portage-4df7a0a0c16c5ded65ad601d39840797b7704770.tar.bz2 portage-4df7a0a0c16c5ded65ad601d39840797b7704770.zip |
ForkExecutor: use async_start method
Also, fix AsynchronousTask.async_start to handle cancellation of the
_async_start coroutine, ensuring that start and exit listeners are
notified in this case (otherwise RetryForkExecutorTestCase will hang).
Signed-off-by: Zac Medico <zmedico@gentoo.org>
Diffstat (limited to 'lib/_emerge/AsynchronousTask.py')
-rw-r--r-- | lib/_emerge/AsynchronousTask.py | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/lib/_emerge/AsynchronousTask.py b/lib/_emerge/AsynchronousTask.py index d1e23cdf1..1e9e177cb 100644 --- a/lib/_emerge/AsynchronousTask.py +++ b/lib/_emerge/AsynchronousTask.py @@ -25,8 +25,19 @@ class AsynchronousTask(SlotObject): @coroutine def async_start(self): - yield self._async_start() - self._start_hook() + try: + if self._was_cancelled(): + raise asyncio.CancelledError + yield self._async_start() + if self._was_cancelled(): + raise asyncio.CancelledError + except asyncio.CancelledError: + self.cancel() + self._was_cancelled() + self._async_wait() + raise + finally: + self._start_hook() @coroutine def _async_start(self): |