I have two processes, one adds jobs to a queue and the other takes them off the same queue and runs them. This should work as expected and I'm not sure why the worker
never gets any jobs. Here's my code:
from multiprocessing import Process
from Queue import Queue
import time
q = Queue()
def queuer():
while True:
q.put("JOB")
print "Adding JOB"
time.sleep(1)
def worker():
while True:
if not q.empty():
item = q.get()
print "Running", item
else:
print "No jobs"
time.sleep(1)
a = Process(target=queuer)
a.start()
b = Process(target=worker)
b.start()