public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Zac Medico" <zmedico@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/portage:master commit in: lib/portage/tests/ebuild/, lib/_emerge/
Date: Tue, 24 Oct 2023 15:31:37 +0000 (UTC)	[thread overview]
Message-ID: <1698120226.79e7024147faff511a69ac725ba63ba71a474aee.zmedico@gentoo> (raw)

commit:     79e7024147faff511a69ac725ba63ba71a474aee
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Tue Oct 24 03:46:19 2023 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Tue Oct 24 04:03:46 2023 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=79e70241

EbuildFetcher: multiprocessing spawn compat

Tested with this script:

import contextlib
import multiprocessing
import unittest

from portage.tests.conftest import prepare_environment
from portage.tests.ebuild.test_fetch import EbuildFetchTestCase

if __name__ == "__main__":
    multiprocessing.set_start_method("spawn", force=True)
    with contextlib.contextmanager(prepare_environment.__wrapped__)():
        unittest.main()

Bug: https://bugs.gentoo.org/914876
Signed-off-by: Zac Medico <zmedico <AT> gentoo.org>

 lib/_emerge/EbuildFetcher.py           | 12 ++++--------
 lib/portage/tests/ebuild/test_fetch.py | 24 ++++++++++++++----------
 2 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/lib/_emerge/EbuildFetcher.py b/lib/_emerge/EbuildFetcher.py
index edabe54456..7a45d95172 100644
--- a/lib/_emerge/EbuildFetcher.py
+++ b/lib/_emerge/EbuildFetcher.py
@@ -250,8 +250,7 @@ class _EbuildFetcherProcess(ForkProcess):
         self.target = functools.partial(
             self._target,
             self._settings,
-            self._get_digests,
-            self._get_manifest,
+            self._get_manifest(),
             self._uri_map,
             self.fetchonly,
         )
@@ -264,10 +263,7 @@ class _EbuildFetcherProcess(ForkProcess):
         self._settings = None
 
     @staticmethod
-    def _target(settings, get_digests, get_manifest, uri_map, fetchonly):
-        """
-        TODO: Make all arguments picklable for the multiprocessing spawn start method.
-        """
+    def _target(settings, manifest, uri_map, fetchonly):
         # Force consistent color output, in case we are capturing fetch
         # output through a normal pipe due to unavailability of ptys.
         portage.output.havecolor = settings.get("NOCOLOR") not in ("yes", "true")
@@ -278,12 +274,12 @@ class _EbuildFetcherProcess(ForkProcess):
             _drop_privs_userfetch(settings)
 
         rval = 1
-        allow_missing = get_manifest().allow_missing or "digest" in settings.features
+        allow_missing = manifest.allow_missing or "digest" in settings.features
         if fetch(
             uri_map,
             settings,
             fetchonly=fetchonly,
-            digests=copy.deepcopy(get_digests()),
+            digests=copy.deepcopy(manifest.getTypeDigests("DIST")),
             allow_missing_digests=allow_missing,
         ):
             rval = os.EX_OK

diff --git a/lib/portage/tests/ebuild/test_fetch.py b/lib/portage/tests/ebuild/test_fetch.py
index 76dcdaf88c..a9ca030ff9 100644
--- a/lib/portage/tests/ebuild/test_fetch.py
+++ b/lib/portage/tests/ebuild/test_fetch.py
@@ -335,16 +335,7 @@ class EbuildFetchTestCase(TestCase):
                     )
                 )
 
-            # Tests only work with one ebuild at a time, so the config
-            # pool only needs a single config instance.
-            class config_pool:
-                @staticmethod
-                def allocate():
-                    return settings
-
-                @staticmethod
-                def deallocate(settings):
-                    pass
+            config_pool = config_pool_cls(settings)
 
             def async_fetch(pkg, ebuild_path):
                 fetcher = EbuildFetcher(
@@ -880,3 +871,16 @@ class EbuildFetchTestCase(TestCase):
                         self.assertEqual(filename_result, str(filename))
             finally:
                 shutil.rmtree(distdir)
+
+
+# Tests only work with one ebuild at a time, so the config
+# pool only needs a single config instance.
+class config_pool_cls:
+    def __init__(self, settings):
+        self._settings = settings
+
+    def allocate(self):
+        return self._settings
+
+    def deallocate(self, settings):
+        pass


                 reply	other threads:[~2023-10-24 15:31 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1698120226.79e7024147faff511a69ac725ba63ba71a474aee.zmedico@gentoo \
    --to=zmedico@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox