X-Git-Url: https://wannabe.guru.org/gitweb/?a=blobdiff_plain;f=tests%2Fparallelize_itest.py;h=ef154a70d92eb4a32339bc4eb5a121561878aa50;hb=532df2c5b57c7517dfb3dddd8c1358fbadf8baf3;hp=11c5676173ce584ae1f6a13fb3c5c1e3d8549b5b;hpb=eedcbd4f64af13ec2098508c3d839a60f7e9ffce;p=python_utils.git diff --git a/tests/parallelize_itest.py b/tests/parallelize_itest.py index 11c5676..ef154a7 100755 --- a/tests/parallelize_itest.py +++ b/tests/parallelize_itest.py @@ -1,13 +1,20 @@ #!/usr/bin/env python3 +# © Copyright 2021-2022, Scott Gasch + +"""parallelize unittest.""" + +import logging import sys import bootstrap -import parallelize as p import decorator_utils import executors +import parallelize as p import smart_future +logger = logging.getLogger(__name__) + @p.parallelize(method=p.Method.THREAD) def compute_factorial_thread(n): @@ -37,7 +44,8 @@ def compute_factorial_remote(n): def test_thread_parallelization() -> None: results = [] for _ in range(50): - results.append(compute_factorial_thread(_)) + f = compute_factorial_thread(_) + results.append(f) smart_future.wait_all(results) for future in results: print(f'Thread: {future}') @@ -59,7 +67,7 @@ def test_process_parallelization() -> None: @decorator_utils.timed def test_remote_parallelization() -> None: results = [] - for _ in range(50): + for _ in range(10): results.append(compute_factorial_remote(_)) for result in smart_future.wait_any(results): print(result) @@ -76,4 +84,8 @@ def main() -> None: if __name__ == '__main__': - main() + try: + main() + except Exception as e: + logger.exception(e) + sys.exit(1)