9 import parallelize as p
12 logger = logging.getLogger(__name__)
15 @p.parallelize(method=p.Method.THREAD)
16 def compute_factorial_thread(n):
23 @p.parallelize(method=p.Method.PROCESS)
24 def compute_factorial_process(n):
31 @p.parallelize(method=p.Method.REMOTE)
32 def compute_factorial_remote(n):
39 @decorator_utils.timed
40 def test_thread_parallelization() -> None:
43 f = compute_factorial_thread(_)
45 smart_future.wait_all(results)
46 for future in results:
47 print(f'Thread: {future}')
48 texecutor = executors.DefaultExecutors().thread_pool()
52 @decorator_utils.timed
53 def test_process_parallelization() -> None:
56 results.append(compute_factorial_process(_))
57 for future in smart_future.wait_any(results):
58 print(f'Process: {future}')
59 pexecutor = executors.DefaultExecutors().process_pool()
63 @decorator_utils.timed
64 def test_remote_parallelization() -> None:
67 results.append(compute_factorial_remote(_))
68 for result in smart_future.wait_any(results):
70 rexecutor = executors.DefaultExecutors().remote_pool()
76 test_thread_parallelization()
77 test_process_parallelization()
78 test_remote_parallelization()
82 if __name__ == '__main__':
85 except Exception as e: