Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
an example of concurrent.futures.ProcessPoolExecutor for python 2.7
import concurrent.futures
import time
def sleep_print_return(input):
print "{} started".format(input)
time.sleep(input % 3)
return input
def main():
# to observe the difference, change max_workers to 1
with concurrent.futures.ProcessPoolExecutor(max_workers=None) as executor:
for result in executor.map(sleep_print_return, range(25)):
# do stuff
print "{} finished".format(result)
pass
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.