Gentoo Archives: gentoo-portage-dev

From: Zac Medico <zmedico@g.o>
To: gentoo-portage-dev@l.g.o
Cc: Zac Medico <zmedico@g.o>
Subject: [gentoo-portage-dev] [PATCH 3/6] Binpkg: use async_lock (bug 614112)
Date: Sat, 21 Apr 2018 08:28:31
Message-Id: 20180421082440.32706-4-zmedico@gentoo.org
In Reply to: [gentoo-portage-dev] [PATCH 0/6] EbuildBuildDir: add async_lock method (bug 614112) by Zac Medico
1 Asynchronously lock the build directory, and use AsyncTaskFuture
2 to fit the resulting future into the CompositeTask framework that
3 Binpkg uses.
4
5 Bug: https://bugs.gentoo.org/614112
6 ---
7 pym/_emerge/Binpkg.py | 16 +++++++++++++---
8 1 file changed, 13 insertions(+), 3 deletions(-)
9
10 diff --git a/pym/_emerge/Binpkg.py b/pym/_emerge/Binpkg.py
11 index 09a1fe680..e9c5ef568 100644
12 --- a/pym/_emerge/Binpkg.py
13 +++ b/pym/_emerge/Binpkg.py
14 @@ -112,15 +112,25 @@ class Binpkg(CompositeTask):
15 self.wait()
16 return
17
18 - pkg = self.pkg
19 - pkg_count = self.pkg_count
20 if not (self.opts.pretend or self.opts.fetchonly):
21 - self._build_dir.lock()
22 + self._start_task(
23 + AsyncTaskFuture(future=self._build_dir.async_lock()),
24 + self._start_fetcher)
25 + else:
26 + self._start_fetcher()
27 +
28 + def _start_fetcher(self, lock_task=None):
29 + if lock_task is not None:
30 + self._assert_current(lock_task)
31 + lock_task.future.result()
32 # Initialize PORTAGE_LOG_FILE (clean_log won't work without it).
33 portage.prepare_build_dirs(self.settings["ROOT"], self.settings, 1)
34 # If necessary, discard old log so that we don't
35 # append to it.
36 self._build_dir.clean_log()
37 +
38 + pkg = self.pkg
39 + pkg_count = self.pkg_count
40 fetcher = BinpkgFetcher(background=self.background,
41 logfile=self.settings.get("PORTAGE_LOG_FILE"), pkg=self.pkg,
42 pretend=self.opts.pretend, scheduler=self.scheduler)
43 --
44 2.13.6