Skip to content

Instantly share code, notes, and snippets.

@zed zed/use-pool.py Secret
Created Nov 24, 2013

Embed
What would you like to do?
#!/usr/bin/env python
"""
http://stackoverflow.com/questions/20167735/python-multiprocessing-pipe-deadlock
"""
import logging
import multiprocessing as mp
def process(item):
print("adding ", item, "to done queue")
return item*100000
def main():
mp.log_to_stderr().setLevel(logging.DEBUG)
pool = mp.Pool(processes=4)
items = ("hi"+str(x) for x in range(10))
for result in pool.imap_unordered(process, items, chunksize=2):
print(len(result))
pool.close()
pool.join()
if __name__ == '__main__':
mp.freeze_support()
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.