Created
December 17, 2016 21:43
-
-
Save SamirBoulil/ca2f1f6729340b648d0788b1bc6857e6 to your computer and use it in GitHub Desktop.
Simple Consumer & Queue implementation with python multiprocessing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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