projects
/
python_utils.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Separate box and print_box.
[python_utils.git]
/
tests
/
parallelize_itest.py
diff --git
a/tests/parallelize_itest.py
b/tests/parallelize_itest.py
index 11c5676173ce584ae1f6a13fb3c5c1e3d8549b5b..409b8dc174078b1c5810098e290c042a1e9f38c3 100755
(executable)
--- a/
tests/parallelize_itest.py
+++ b/
tests/parallelize_itest.py
@@
-1,13
+1,16
@@
#!/usr/bin/env python3
#!/usr/bin/env python3
+import logging
import sys
import bootstrap
import sys
import bootstrap
-import parallelize as p
import decorator_utils
import executors
import decorator_utils
import executors
+import parallelize as p
import smart_future
import smart_future
+logger = logging.getLogger(__name__)
+
@p.parallelize(method=p.Method.THREAD)
def compute_factorial_thread(n):
@p.parallelize(method=p.Method.THREAD)
def compute_factorial_thread(n):
@@
-37,7
+40,8
@@
def compute_factorial_remote(n):
def test_thread_parallelization() -> None:
results = []
for _ in range(50):
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}')
smart_future.wait_all(results)
for future in results:
print(f'Thread: {future}')
@@
-59,7
+63,7
@@
def test_process_parallelization() -> None:
@decorator_utils.timed
def test_remote_parallelization() -> None:
results = []
@decorator_utils.timed
def test_remote_parallelization() -> None:
results = []
- for _ in range(
5
0):
+ for _ in range(
1
0):
results.append(compute_factorial_remote(_))
for result in smart_future.wait_any(results):
print(result)
results.append(compute_factorial_remote(_))
for result in smart_future.wait_any(results):
print(result)
@@
-76,4
+80,8
@@
def main() -> None:
if __name__ == '__main__':
if __name__ == '__main__':
- main()
+ try:
+ main()
+ except Exception as e:
+ logger.exception(e)
+ sys.exit(1)