From 9da3fa0b23b6339e5ec8fd4497886690ce118926 Mon Sep 17 00:00:00 2001 From: 3DAlgoLab <83936830+3DAlgoLab@users.noreply.github.com> Date: Fri, 18 Mar 2022 11:23:00 +0900 Subject: [PATCH 1/2] Update example3.py After call apply_async, we shoud wait its result. --- Chapter15/example3.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Chapter15/example3.py b/Chapter15/example3.py index d5b085b..d6f326a 100644 --- a/Chapter15/example3.py +++ b/Chapter15/example3.py @@ -43,8 +43,10 @@ def countdown(n): pool = Pool(processes=2) start = time.time() - pool.apply_async(countdown, args=(COUNT//2,)) - pool.apply_async(countdown, args=(COUNT//2,)) + r1 = pool.apply_async(countdown, args=(COUNT//2,)) + r2 = pool.apply_async(countdown, args=(COUNT//2,)) + r1.wait() # it should be wait to measure its completion time. + r2.wait() pool.close() pool.join() From 48e4cb4878830b5f3e23346187ba8ada37f1dd2c Mon Sep 17 00:00:00 2001 From: 3DAlgoLab <83936830+3DAlgoLab@users.noreply.github.com> Date: Fri, 18 Mar 2022 12:24:57 +0900 Subject: [PATCH 2/2] Update example3.py fix a typo. --- Chapter15/example3.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Chapter15/example3.py b/Chapter15/example3.py index d6f326a..77d1489 100644 --- a/Chapter15/example3.py +++ b/Chapter15/example3.py @@ -45,7 +45,7 @@ def countdown(n): start = time.time() r1 = pool.apply_async(countdown, args=(COUNT//2,)) r2 = pool.apply_async(countdown, args=(COUNT//2,)) - r1.wait() # it should be wait to measure its completion time. + r1.wait() # it should wait to measure its completion time. r2.wait() pool.close() pool.join()