Raymond Hettinger <[email protected]> added the comment:
I'm thinking of simplifying the example to focus on its core goal of
demonstrating how to enqueue tasks and then wait for them to be finished:
import threading, queue
q = queue.Queue()
def worker():
while True:
item = q.get()
print(f'Working on {item}')
print(f'Finished {item}')
q.task_done()
# turn-on the worker thread
worker_thread = threading.Thread(target=worker)
worker_thread.daemon = True
worker_thread.start()
# send thirty task requests to the worker
for item in range(30):
q.put(item)
print('All task requests sent\n', end='')
# block until all tasks are done
q.join()
print('All work completed')
----------
assignee: docs@python -> rhettinger
title: queue example it does not work -> queue example is a sketch
versions: -Python 3.7
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue40387>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com