Teile 10 bis 12.

This commit is contained in:
2023-03-28 12:26:50 +02:00
parent 298151634d
commit f7a5db9f39
27 changed files with 6459 additions and 75 deletions

20
teil12/pool3.py Normal file
View File

@@ -0,0 +1,20 @@
# Quelle: https://www.codesdope.com/blog/article/multiprocessing-using-pool-in-python/
import time
from multiprocessing import Pool
def square(x):
print(f"start process:{x}")
square = x * x
print(f"square {x}:{square}")
time.sleep(1)
print(f"end process:{x}")
if __name__ == "__main__":
starttime = time.time()
pool = Pool()
pool.map(square, range(0, 5))
pool.close()
endtime = time.time()
print(f"Time taken {endtime-starttime} seconds")