Created
February 27, 2020 23:03
-
-
Save shcallaway/84a675a0072a7f0a2978d13aa3a5b29c to your computer and use it in GitHub Desktop.
Demo script to illustrate how multiprocessing.Pool.map is blocking
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
import multiprocessing | |
def delay_print(message): | |
time.sleep(1) | |
print(message) | |
for i in range(10): | |
# multiprocessing.Pool.map is blocking. | |
# The next iteration of the loop will not run until after all workers have completed their tasks. | |
multiprocessing.Pool(1).map(delay_print, [i]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment