diff options
Diffstat (limited to 'lib/python/qmk/util.py')
-rw-r--r-- | lib/python/qmk/util.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/python/qmk/util.py b/lib/python/qmk/util.py index db7debd578..0145ab1354 100644 --- a/lib/python/qmk/util.py +++ b/lib/python/qmk/util.py @@ -2,9 +2,30 @@ """ import contextlib import multiprocessing +import sys from milc import cli +maybe_exit_should_exit = True +maybe_exit_reraise = False + + +# Controls whether or not early `exit()` calls should be made +def maybe_exit(rc): + if maybe_exit_should_exit: + sys.exit(rc) + if maybe_exit_reraise: + e = sys.exception() + if e: + raise e + + +def maybe_exit_config(should_exit: bool = True, should_reraise: bool = False): + global maybe_exit_should_exit + global maybe_exit_reraise + maybe_exit_should_exit = should_exit + maybe_exit_reraise = should_reraise + @contextlib.contextmanager def parallelize(): |