You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildstream.apache.org by no...@apache.org on 2020/12/29 12:48:43 UTC

[buildstream] 02/27: WIP: work around multiple set_start_method

This is an automated email from the ASF dual-hosted git repository.

not-in-ldap pushed a commit to branch aevri/check_spawn_ci_working
in repository https://gitbox.apache.org/repos/asf/buildstream.git

commit 6fe49aa2e6d42d4ace5c79c33986acdb3c984440
Author: Angelos Evripiotis <je...@bloomberg.net>
AuthorDate: Wed Oct 16 11:47:36 2019 +0100

    WIP: work around multiple set_start_method
---
 src/buildstream/_frontend/cli.py | 26 +++++++++++++++++++-------
 1 file changed, 19 insertions(+), 7 deletions(-)

diff --git a/src/buildstream/_frontend/cli.py b/src/buildstream/_frontend/cli.py
index 60527e6..05c0bd2 100644
--- a/src/buildstream/_frontend/cli.py
+++ b/src/buildstream/_frontend/cli.py
@@ -232,13 +232,25 @@ def override_main(self, args=None, prog_name=None, complete_var=None,
     # reason we're advised to do it inside the entrypoint, where it is easy to
     # ensure the code path is only followed once.
     if 'BST_FORCE_START_METHOD' in os.environ:
-        multiprocessing.set_start_method(os.environ['BST_FORCE_START_METHOD'])
-        print(
-            "BST_FORCE_START_METHOD: multiprocessing start method forced to:",
-            os.environ['BST_FORCE_START_METHOD'],
-            file=sys.stderr,
-            flush=True,
-        )
+        start_method = os.environ['BST_FORCE_START_METHOD']
+        if multiprocessing.get_start_method(allow_none=True) == start_method:
+            # Note that when testing, we run the buildstream entrypoint
+            # multiple times in the same executable, so guard against that
+            # here.
+            print(
+                "BST_FORCE_START_METHOD: multiprocessing start method already set to:",
+                start_method,
+                file=sys.stderr,
+                flush=True,
+            )
+        else:
+            multiprocessing.set_start_method(start_method)
+            print(
+                "BST_FORCE_START_METHOD: multiprocessing start method forced to:",
+                start_method,
+                file=sys.stderr,
+                flush=True,
+            )
 
     original_main(self, args=args, prog_name=prog_name, complete_var=None,
                   standalone_mode=standalone_mode, **extra)