Skip to content

Instantly share code, notes, and snippets.

@shcallaway
Created February 27, 2020 23:03
Show Gist options
  • Save shcallaway/84a675a0072a7f0a2978d13aa3a5b29c to your computer and use it in GitHub Desktop.
Save shcallaway/84a675a0072a7f0a2978d13aa3a5b29c to your computer and use it in GitHub Desktop.
Demo script to illustrate how multiprocessing.Pool.map is blocking
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