8 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 f = compute_factorial_thread(_)
42 smart_future.wait_all(results)
43 for future in results:
44 print(f'Thread: {future}')
45 texecutor = executors.DefaultExecutors().thread_pool()
49 @decorator_utils.timed
50 def test_process_parallelization() -> None:
53 results.append(compute_factorial_process(_))
54 for future in smart_future.wait_any(results):
55 print(f'Process: {future}')
56 pexecutor = executors.DefaultExecutors().process_pool()
60 @decorator_utils.timed
61 def test_remote_parallelization() -> None:
64 results.append(compute_factorial_remote(_))
65 for result in smart_future.wait_any(results):
67 rexecutor = executors.DefaultExecutors().remote_pool()
73 test_thread_parallelization()
74 test_process_parallelization()
75 test_remote_parallelization()
79 if __name__ == '__main__':