A consumer thread (modeled by threading.Thread) contains a infinite loop that queries the queue for more work, submits future's when a datum is found in the queue. The consumer thread is set to a daemon state, such that when there is no work left and the producer process has terminated, it dies as well:
class ConsumerProcess(Thread):
def run(self):
global buffer_queue, launches
while True:
item = buffer_queue.get()
launch = futures.submit(consume, item)
launches.append(launch)
After running the code on a single node with 8 CPUs, I analyze the output (see below) and see messages "Lost track of future", produced by the scoopzmq module.
nickv@pharos:~/scoop/test_queue$ python -m scoop.__main__ callback_q.py
[2014-10-10 14:14:01,565] launcher INFO SCOOP 0.7.2 dev on linux2 using Python 2.6.5 (r265:79063, Oct 1 2012, 22:04:36) [GCC 4.4.3], API: 1013
[2014-10-10 14:14:01,566] launcher INFO Deploying 8 worker(s) over 1 host(s).
[2014-10-10 14:14:01,566] launcher INFO Worker d--istribution:
[2014-10-10 14:14:01,566] launcher INFO
127.0.0.1: 7 + origin
Launching 8 worker(s) using /bin/bash.
[2014-10-10 14:14:02,153] callback_q (
127.0.0.1:53224) INFO source data: [0, 1, 2, 3, 4]
[2014-10-10 14:14:02,154] callback_q (
127.0.0.1:53224) INFO *** Main thread waiting...
[2014-10-10 14:14:02,156] callback_q (
127.0.0.1:53224) INFO Producer thread is released!
[2014-10-10 14:14:02,157] callback_q (
127.0.0.1:53224) INFO Processing item 0
[2014-10-10 14:14:02,160] callback_q (
127.0.0.1:59059) INFO Processing item 4
[2014-10-10 14:14:02,161] callback_q (
127.0.0.1:59175) INFO Processing item 3
[2014-10-10 14:14:02,169] callback_q (
127.0.0.1:49676) INFO Processing item 2
[2014-10-10 14:14:02,170] callback_q (
127.0.0.1:53240) INFO Processing item 1
[2014-10-10 14:14:05,174] callback_q (
127.0.0.1:50002) INFO Processing item 4
[2014-10-10 14:14:05,174] callback_q (
127.0.0.1:50542) INFO Processing item 3
[2014-10-10 14:14:07,167] callback_q (
127.0.0.1:53224) INFO product data: [4, 3, 2, 1, 0]
[2014-10-10 14:14:07,167] callback_q (
127.0.0.1:53224) INFO Time in broker node: 5.01436805725 seconds
[2014-10-10 14:14:07,206] launcher (
127.0.0.1:59054) INFO Root process is done.
[2014-10-10 14:14:07,206] launcher (
127.0.0.1:59054) INFO Finished cleaning spawned subprocesses.