This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients docs@python, pitrou, rhettinger, vstinner
Date 2011-05-24.07:32:36
SpamBayes Score 1.6400823e-05
Marked as misclassified No
Message-id <1306222357.13.0.382806629523.issue12155@psf.upfronthosting.co.za>
In-reply-to
Content
> Is it unclear to you what those mean?

Well, it's clear, but I like when I can simply copy/paste the example and it does just work:

> If you post a high-quality self-contained example somewhere 
> on the net, I would be happy to link to it.

I just propose to change the example to stop the threads:
------------------
def worker():
    while True:
        item = q.get()
        if item is None:
            break
        do_work(item)
        q.task_done()

q = Queue()
threads = []
for i in range(num_worker_threads):
     t = Thread(target=worker)
     threads.append(t)
     t.start()

for item in source():
    q.put(item)

q.join()       # block until all tasks are done
for i in range(num_worker_threads):
    q.put(None)
for t in threads: t.join()
------------------
History
Date User Action Args
2011-05-24 07:32:37vstinnersetrecipients: + vstinner, rhettinger, pitrou, docs@python
2011-05-24 07:32:37vstinnersetmessageid: <1306222357.13.0.382806629523.issue12155@psf.upfronthosting.co.za>
2011-05-24 07:32:36vstinnerlinkissue12155 messages
2011-05-24 07:32:36vstinnercreate