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 @@ | |||
| 2 | """ | 2 | """ |
| 3 | import contextlib | 3 | import contextlib |
| 4 | import multiprocessing | 4 | import multiprocessing |
| 5 | import sys | ||
| 5 | 6 | ||
| 6 | from milc import cli | 7 | from milc import cli |
| 7 | 8 | ||
| 9 | maybe_exit_should_exit = True | ||
| 10 | maybe_exit_reraise = False | ||
| 11 | |||
| 12 | |||
| 13 | # Controls whether or not early `exit()` calls should be made | ||
| 14 | def maybe_exit(rc): | ||
| 15 | if maybe_exit_should_exit: | ||
| 16 | sys.exit(rc) | ||
| 17 | if maybe_exit_reraise: | ||
| 18 | e = sys.exception() | ||
| 19 | if e: | ||
| 20 | raise e | ||
| 21 | |||
| 22 | |||
| 23 | def maybe_exit_config(should_exit: bool = True, should_reraise: bool = False): | ||
| 24 | global maybe_exit_should_exit | ||
| 25 | global maybe_exit_reraise | ||
| 26 | maybe_exit_should_exit = should_exit | ||
| 27 | maybe_exit_reraise = should_reraise | ||
| 28 | |||
| 8 | 29 | ||
| 9 | @contextlib.contextmanager | 30 | @contextlib.contextmanager |
| 10 | def parallelize(): | 31 | def parallelize(): |
