diff options
author | Zac Medico <zmedico@gentoo.org> | 2019-11-06 00:03:36 -0800 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2019-11-06 12:05:27 -0800 |
commit | 7b8f57335c43054fe4008b7401d6ac2b3f710c1a (patch) | |
tree | afd788a01ae00478a82d67e66e4b45f227867512 /lib/portage/util/_async | |
parent | emirrordist: _make_layout_links msg UnboundLocalError (diff) | |
download | portage-7b8f57335c43054fe4008b7401d6ac2b3f710c1a.tar.gz portage-7b8f57335c43054fe4008b7401d6ac2b3f710c1a.tar.bz2 portage-7b8f57335c43054fe4008b7401d6ac2b3f710c1a.zip |
FileCopier: capture exceptions
Use ForkExecutor to capture exceptions instead of showing
a full traceback. FileCopier callers will now be responsible
for displaying relevant exception messages.
Bug: https://bugs.gentoo.org/699400
Signed-off-by: Zac Medico <zmedico@gentoo.org>
Diffstat (limited to 'lib/portage/util/_async')
-rw-r--r-- | lib/portage/util/_async/FileCopier.py | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/lib/portage/util/_async/FileCopier.py b/lib/portage/util/_async/FileCopier.py index 27e5ab4c0..3a0be4b63 100644 --- a/lib/portage/util/_async/FileCopier.py +++ b/lib/portage/util/_async/FileCopier.py @@ -1,17 +1,19 @@ -# Copyright 2013 Gentoo Foundation +# Copyright 2013-2019 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 -from portage import os from portage import shutil -from portage.util._async.ForkProcess import ForkProcess +from portage.util.futures import asyncio +from portage.util.futures.executor.fork import ForkExecutor +from portage.util._async.AsyncTaskFuture import AsyncTaskFuture -class FileCopier(ForkProcess): +class FileCopier(AsyncTaskFuture): """ Asynchronously copy a file. """ __slots__ = ('src_path', 'dest_path') - def _run(self): - shutil.copy(self.src_path, self.dest_path) - return os.EX_OK + def _start(self): + self.future = asyncio.ensure_future(self.scheduler.run_in_executor(ForkExecutor(loop=self.scheduler), + shutil.copy, self.src_path, self.dest_path)) + super(FileCopier, self)._start() |