From 11f98d078fde7ca8d7157078462bc3d179db4948 Mon Sep 17 00:00:00 2001 From: Roland Thomas Date: Sun, 12 May 2024 22:42:11 -0400 Subject: [PATCH] black formatting --- thread_pool_patterns/submit_use_as_completed.py | 2 +- thread_pool_patterns/submit_use_callback.py | 3 ++- thread_pool_patterns/submit_use_sequentially.py | 2 +- thread_pool_patterns/submit_wait_first.py | 3 ++- thread_pool_patterns/submit_wait_for_all.py | 7 +++++-- 5 files changed, 11 insertions(+), 6 deletions(-) diff --git a/thread_pool_patterns/submit_use_as_completed.py b/thread_pool_patterns/submit_use_as_completed.py index e62bf84..4df4d87 100755 --- a/thread_pool_patterns/submit_use_as_completed.py +++ b/thread_pool_patterns/submit_use_as_completed.py @@ -6,7 +6,7 @@ from concurrent.futures import ThreadPoolExecutor, as_completed def add_one(number): print(number) - sleep(randint(0,2)) + sleep(randint(0, 2)) return number + 1 diff --git a/thread_pool_patterns/submit_use_callback.py b/thread_pool_patterns/submit_use_callback.py index c2278be..207b518 100755 --- a/thread_pool_patterns/submit_use_callback.py +++ b/thread_pool_patterns/submit_use_callback.py @@ -6,8 +6,9 @@ from concurrent.futures import ThreadPoolExecutor, Future results: list[int] = [] + def add_one(number: int) -> int: - sleep(randint(0,2)) + sleep(randint(0, 2)) result = number + 1 return result diff --git a/thread_pool_patterns/submit_use_sequentially.py b/thread_pool_patterns/submit_use_sequentially.py index 436b240..462790e 100755 --- a/thread_pool_patterns/submit_use_sequentially.py +++ b/thread_pool_patterns/submit_use_sequentially.py @@ -6,7 +6,7 @@ from concurrent.futures import ThreadPoolExecutor def add_one(number): print(number) - sleep(randint(0,2)) + sleep(randint(0, 2)) return number + 1 diff --git a/thread_pool_patterns/submit_wait_first.py b/thread_pool_patterns/submit_wait_first.py index c8707ca..e96d780 100755 --- a/thread_pool_patterns/submit_wait_first.py +++ b/thread_pool_patterns/submit_wait_first.py @@ -5,8 +5,9 @@ from concurrent.futures import ThreadPoolExecutor, Future, wait, FIRST_COMPLETED results: list[int] = [] + def add_one(number: int) -> int: - sleep(randint(0,2)) + sleep(randint(0, 2)) return number + 1 diff --git a/thread_pool_patterns/submit_wait_for_all.py b/thread_pool_patterns/submit_wait_for_all.py index 1185054..d5450cf 100755 --- a/thread_pool_patterns/submit_wait_for_all.py +++ b/thread_pool_patterns/submit_wait_for_all.py @@ -5,9 +5,10 @@ from concurrent.futures import ThreadPoolExecutor, wait, Future results: list[int] = [] + def add_one(number: int) -> int: print(number) - sleep(randint(0,2)) + sleep(randint(0, 2)) return number + 1 @@ -28,7 +29,9 @@ def main() -> None: print("All done!") with ThreadPoolExecutor() as executor: - futures: list[Future] = [executor.submit(add_one, number) for number in range(10)] + futures: list[Future] = [ + executor.submit(add_one, number) for number in range(10) + ] print("Done waiting!") for future in futures: print(future.result())