Join us and get access to hundreds of tutorials and a community of expert Pythonistas.

Unlock This Lesson

This lesson is for members only. Join us and get access to hundreds of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Hint: You can adjust the default video playback speed in your account settings.
Hint: You can set the default subtitles language in your account settings.
Sorry! Looks like there’s an issue with video playback 🙁 This might be due to a temporary outage or because of a configuration issue with your browser. Please see our video player troubleshooting guide to resolve the issue.

The queue Module: Part 2

Give Feedback

In this lesson, you’ll finish creating your message queue and analyze the output of the program. If you download the sample code, you can get your own copy of 13-queue.py:

Download

Sample Code (.zip)

12.9 KB

To learn more, you can also check out the documentation for threading.Event, the queue module, and super.

Pradeep Kumar on Aug. 29, 2020

It was a great tutorial, I am just curious to know, why it is giving +2 results, for example: maxsize = 10 , it is producing 12 outcomes and for maxsize = 20 , it is producing 22 outcomes. I am not sure why it is like that?

Bartosz Zaczyński RP Team on Aug. 31, 2020

In fact, it’s not always +2. The maxsize parameter determines the queue’s maximum capacity, while the total number of elements pushed through it will vary depending on how quickly they’re produced and consumed. When you comment out the time.sleep() line from the consumer, you’ll see many more elements in the output.

Become a Member to join the conversation.