Updated h2inc to use multiprocessing

This commit is contained in:
2018-02-16 23:43:30 +01:00
parent 9ab6f60f14
commit 7685b8c6a8
8 changed files with 170 additions and 88 deletions
+20
View File
@@ -0,0 +1,20 @@
from multiprocessing import Pool
import time
work = (["A", 5], ["B", 2], ["C", 1], ["D", 3])
def work_log(work_data):
print(" Process %s waiting %s seconds" % (work_data[0], work_data[1]))
time.sleep(int(work_data[1]))
print(" Process %s Finished." % work_data[0])
def pool_handler():
p = Pool(2)
p.map(work_log, work)
if __name__ == '__main__':
pool_handler()