Skip to content

Instantly share code, notes, and snippets.

@SamirBoulil
Created December 17, 2016 21:43
Show Gist options
  • Save SamirBoulil/ca2f1f6729340b648d0788b1bc6857e6 to your computer and use it in GitHub Desktop.
Save SamirBoulil/ca2f1f6729340b648d0788b1bc6857e6 to your computer and use it in GitHub Desktop.
Simple Consumer & Queue implementation with python multiprocessing
# coding: utf-8
import multiprocessing as mp
def loop_a(q):
while not q.empty():
print(q.get())
if __name__ == '__main__':
q1=mp.Queue()
p1 = mp.Process(target=loop_a,args=(q1,))
p1.start()
for k in xrange(1,10):
q1.put(k)
q1.close()
q1.join_thread()
p1.join()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment