diff options
| author | Angelos Evripiotis <jevripiotis@bloomberg.net> | 2019-10-16 14:43:38 +0100 |
|---|---|---|
| committer | Angelos Evripiotis <jevripiotis@bloomberg.net> | 2019-10-16 14:43:38 +0100 |
| commit | 303cf5a602ffd7612d418f71a833d045ab273374 (patch) | |
| tree | b53ae7686deca82dde018d14d137a107151b6363 | |
| parent | 8d838d452a3d55b300531f74985db45af913aea6 (diff) | |
| download | buildstream-303cf5a602ffd7612d418f71a833d045ab273374.tar.gz | |
WIP: warn on already set start method
| -rw-r--r-- | src/buildstream/_frontend/cli.py | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/src/buildstream/_frontend/cli.py b/src/buildstream/_frontend/cli.py index 05c0bd21b..cd31c5b7d 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) |
