diff options
author | Angelos Evripiotis <jevripiotis@bloomberg.net> | 2019-08-01 10:37:18 +0100 |
---|---|---|
committer | bst-marge-bot <marge-bot@buildstream.build> | 2019-08-16 15:42:35 +0000 |
commit | f1db68f8f82aeb6bbf696c88932411e888c97be3 (patch) | |
tree | 98a640d09a0434f595f8d6b9fae79a6678039995 | |
parent | 9ab14764081bf88fdeb22e2ab7ab3eb345e1bf0d (diff) | |
download | buildstream-f1db68f8f82aeb6bbf696c88932411e888c97be3.tar.gz |
_frontend/cli: support 'BST_FORCE_START_METHOD'
Allow users to force the start method via a 'BST_FORCE_START_METHOD'
environment variable. This enables testing of the 'spawn' and
'forkserver' methods on platforms that don't require them.
-rw-r--r-- | src/buildstream/_frontend/cli.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/buildstream/_frontend/cli.py b/src/buildstream/_frontend/cli.py index 5a585b276..1365cede4 100644 --- a/src/buildstream/_frontend/cli.py +++ b/src/buildstream/_frontend/cli.py @@ -1,3 +1,4 @@ +import multiprocessing import os import sys from functools import partial @@ -217,6 +218,18 @@ def override_main(self, args=None, prog_name=None, complete_var=None, .format(stream.name), err=True) sys.exit(-1) + # We can only set the global multiprocessing start method once; for that + # 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, + ) + original_main(self, args=args, prog_name=prog_name, complete_var=None, standalone_mode=standalone_mode, **extra) |