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:46 UTC

[buildstream] 05/27: WIP: warn on already 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 303cf5a602ffd7612d418f71a833d045ab273374
Author: Angelos Evripiotis <je...@bloomberg.net>
AuthorDate: Wed Oct 16 14:43:38 2019 +0100

    WIP: warn on already set start method
---
 src/buildstream/_frontend/cli.py | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/src/buildstream/_frontend/cli.py b/src/buildstream/_frontend/cli.py
index 05c0bd2..cd31c5b 100644
--- a/src/buildstream/_frontend/cli.py
+++ b/src/buildstream/_frontend/cli.py
@@ -233,24 +233,33 @@ def override_main(self, args=None, prog_name=None, complete_var=None,
     # ensure the code path is only followed once.
     if 'BST_FORCE_START_METHOD' in os.environ:
         start_method = os.environ['BST_FORCE_START_METHOD']
-        if multiprocessing.get_start_method(allow_none=True) == start_method:
+        existing_start_method = multiprocessing.get_start_method(allow_none=True)
+        if existing_start_method == None:
+            multiprocessing.set_start_method(start_method)
+            print(
+                "BST_FORCE_START_METHOD: multiprocessing start method forced to:",
+                start_method,
+                file=sys.stderr,
+                flush=True,
+            )
+        elif existing_start_method == 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,
+                existing_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,
+                "BST_FORCE_START_METHOD: cannot set multiprocessing start method, already set to:",
+                existing_start_method,
                 file=sys.stderr,
                 flush=True,
             )
+            sys.exit(-1)
 
     original_main(self, args=args, prog_name=prog_name, complete_var=None,
                   standalone_mode=standalone_mode, **extra)