#!/usr/bin/env python3
+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):
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}')
@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)
if __name__ == '__main__':
- main()
+ try:
+ main()
+ except Exception as e:
+ logger.exception(e)
+ sys.exit(1)