Skip to content

Instantly share code, notes, and snippets.

@Jotschi
Last active August 29, 2015 13:58
Show Gist options
  • Save Jotschi/9963509 to your computer and use it in GitHub Desktop.
Save Jotschi/9963509 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
from multiprocessing import Pool, Queue
import os
import time
q = Queue()
def worker_main():
print(os.getpid(),"working")
for item in iter(q.get, None):
print(os.getpid(), "got", item)
def main():
p = Pool(3, worker_main, ())
for i in range(10):
q.put("hello")
q.put("world")
for i in range(3):
q.put(None)
p.join()
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment