summaryrefslogtreecommitdiff
path: root/tests/parallelize_itest.py
diff options
context:
space:
mode:
authorScott <[email protected]>2022-01-23 12:43:46 -0800
committerScott <[email protected]>2022-01-23 12:43:46 -0800
commiteedcbd4f64af13ec2098508c3d839a60f7e9ffce (patch)
tree06f656636c8125552bcaad8ba1ad8f342f1d31d3 /tests/parallelize_itest.py
parent2a84ca5a8c75eb7db556b962c645bed79736887b (diff)
Clean up the remote executor stuff and create a dedicated heartbeat
thread. Fix the parallelize integration test. Other changes that depended on these fixes.
Diffstat (limited to 'tests/parallelize_itest.py')
-rwxr-xr-xtests/parallelize_itest.py22
1 files changed, 8 insertions, 14 deletions
diff --git a/tests/parallelize_itest.py b/tests/parallelize_itest.py
index 9d98710..11c5676 100755
--- a/tests/parallelize_itest.py
+++ b/tests/parallelize_itest.py
@@ -1,13 +1,11 @@
#!/usr/bin/env python3
-import random
import sys
import bootstrap
import parallelize as p
import decorator_utils
import executors
-import math_utils
import smart_future
@@ -28,12 +26,11 @@ def compute_factorial_process(n):
@p.parallelize(method=p.Method.REMOTE)
-def list_primes(n):
- """Calculates sum of all primes below given integer n"""
- ret = []
+def compute_factorial_remote(n):
+ total = 1
for x in range(2, n):
- ret.append(math_utils.is_prime(x))
- return ret
+ total *= x
+ return total
@decorator_utils.timed
@@ -61,14 +58,11 @@ def test_process_parallelization() -> None:
@decorator_utils.timed
def test_remote_parallelization() -> None:
- results = {}
+ results = []
for _ in range(50):
- n = random.randint(0, 100000)
- results[n] = list_primes(n)
- tot = 0
- for _ in results[n]:
- tot += _
- print(tot)
+ results.append(compute_factorial_remote(_))
+ for result in smart_future.wait_any(results):
+ print(result)
rexecutor = executors.DefaultExecutors().remote_pool()
rexecutor.shutdown()