-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpool_.py
More file actions
30 lines (23 loc) · 676 Bytes
/
pool_.py
File metadata and controls
30 lines (23 loc) · 676 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#/path/path/
#title :Title
#description :Description.
#update date :01/01/2020 12:10
#version :1.0
#changes :new version changes description.
#python_version :3.6
#==============================================================================
import multiprocessing
from task_function import pool_task
# iterable object
task_params = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
def main():
# create multiprocessing pool
p = multiprocessing.Pool(multiprocessing.cpu_count())
# run the task
res = p.map(pool_task, task_params)
p.close()
p.join()
# print the result
print(res)
if __name__ == "__main__":
main()