Remove print race from task_done example. (GH-31795)

(cherry picked from commit a0eb69c1a2)

Co-authored-by: Raymond Hettinger <rhettinger@users.noreply.github.com>
This commit is contained in:
Miss Islington (bot) 2022-03-10 09:22:46 -08:00 committed by GitHub
parent 5dfe981791
commit 3386f87dcb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -201,15 +201,14 @@ Example of how to wait for enqueued tasks to be completed::
print(f'Finished {item}')
q.task_done()
# turn-on the worker thread
# Turn-on the worker thread.
threading.Thread(target=worker, daemon=True).start()
# send thirty task requests to the worker
# 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
# Block until all tasks are done.
q.join()
print('All work completed')