From cb35e77c38f660a3e8b380e7534f3db499e6d04f Mon Sep 17 00:00:00 2001 From: guanjihuan Date: Thu, 14 Aug 2025 17:59:34 +0800 Subject: [PATCH] Update parallel_calculations_with_python_using_Pool.py --- .../parallel_calculations_with_python_using_Pool.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/2020.06.01_parallel_calculations_with_python/parallel_calculations_with_python_using_Pool.py b/2020.06.01_parallel_calculations_with_python/parallel_calculations_with_python_using_Pool.py index 21a5274..922578f 100644 --- a/2020.06.01_parallel_calculations_with_python/parallel_calculations_with_python_using_Pool.py +++ b/2020.06.01_parallel_calculations_with_python/parallel_calculations_with_python_using_Pool.py @@ -12,10 +12,12 @@ def run_proc(name): time.sleep(2) end_time = time.perf_counter() print ('Process id running on %s = %s' % (name, os.getpid()), '; running time = %s' % (end_time-start_time)) + return name if __name__ == '__main__': start_time = time.time() with multiprocessing.Pool() as pool: - results = pool.map(run_proc, range(64)) + results = pool.map(run_proc, [f"task {i}" for i in range(64)]) end_time = time.time() + print(results) print(end_time - start_time) \ No newline at end of file