6 import parallelize as p
12 @p.parallelize(method=p.Method.THREAD)
13 def compute_factorial_thread(n):
20 @p.parallelize(method=p.Method.PROCESS)
21 def compute_factorial_process(n):
28 @p.parallelize(method=p.Method.REMOTE)
29 def compute_factorial_remote(n):
36 @decorator_utils.timed
37 def test_thread_parallelization() -> None:
40 results.append(compute_factorial_thread(_))
41 smart_future.wait_all(results)
42 for future in results:
43 print(f'Thread: {future}')
44 texecutor = executors.DefaultExecutors().thread_pool()
48 @decorator_utils.timed
49 def test_process_parallelization() -> None:
52 results.append(compute_factorial_process(_))
53 for future in smart_future.wait_any(results):
54 print(f'Process: {future}')
55 pexecutor = executors.DefaultExecutors().process_pool()
59 @decorator_utils.timed
60 def test_remote_parallelization() -> None:
63 results.append(compute_factorial_remote(_))
64 for result in smart_future.wait_any(results):
66 rexecutor = executors.DefaultExecutors().remote_pool()
72 test_thread_parallelization()
73 test_process_parallelization()
74 test_remote_parallelization()
78 if __name__ == '__main__':