diff options
author | Zac Medico <zmedico@gentoo.org> | 2018-05-07 01:14:19 -0700 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2018-05-07 01:17:18 -0700 |
commit | 505707a335683330ac69b1c7f428e8a1c66d0b2e (patch) | |
tree | 8eb338f350e891fbe610ecca0582075899846b03 | |
parent | retry: add loop parameter during decoration (diff) | |
download | portage-505707a335683330ac69b1c7f428e8a1c66d0b2e.tar.gz portage-505707a335683330ac69b1c7f428e8a1c66d0b2e.tar.bz2 portage-505707a335683330ac69b1c7f428e8a1c66d0b2e.zip |
rsync: explicitly use ForkExecutor for key refresh retry (bug 654390)
The ThreadPoolExecutor that asyncio uses by default does not support
cancellation of tasks, therefore use ForkExecutor for task cancellation
support, in order to enforce timeouts.
Bug: https://bugs.gentoo.org/654390
-rw-r--r-- | pym/portage/sync/modules/rsync/rsync.py | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/pym/portage/sync/modules/rsync/rsync.py b/pym/portage/sync/modules/rsync/rsync.py index 070798a53..382a1eaae 100644 --- a/pym/portage/sync/modules/rsync/rsync.py +++ b/pym/portage/sync/modules/rsync/rsync.py @@ -26,6 +26,7 @@ from portage.const import VCS_DIRS, TIMESTAMP_FORMAT, RSYNC_PACKAGE_ATOM from portage.util._eventloop.global_event_loop import global_event_loop from portage.util import writemsg, writemsg_stdout from portage.util.futures import asyncio +from portage.util.futures.executor.fork import ForkExecutor from portage.sync.getaddrinfo_validate import getaddrinfo_validate from _emerge.UserQuery import UserQuery from portage.sync.syncbase import NewBase @@ -170,11 +171,16 @@ class RsyncSync(NewBase): level=logging.ERROR, noiselevel=-1) raise # retry + # The ThreadPoolExecutor that asyncio uses by default + # does not support cancellation of tasks, therefore + # use ForkExecutor for task cancellation support, in + # order to enforce timeouts. loop = global_event_loop() - func_coroutine = functools.partial(loop.run_in_executor, - None, noisy_refresh_keys) - decorated_func = retry_decorator(func_coroutine, loop=loop) - loop.run_until_complete(decorated_func()) + with ForkExecutor(loop=loop) as executor: + func_coroutine = functools.partial(loop.run_in_executor, + executor, noisy_refresh_keys) + decorated_func = retry_decorator(func_coroutine, loop=loop) + loop.run_until_complete(decorated_func()) out.eend(0) except (GematoException, asyncio.TimeoutError) as e: writemsg_level("!!! Manifest verification impossible due to keyring problem:\n%s\n" |