O'Reilly logo

Tkinter GUI Application Development Blueprints - Second Edition by Bhaskar Chaudhary

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using queues

In most cases, it is safer and simpler to use queues. Simply put, a queue is a compound memory structure that is thread-safe. Queues effectively channel access to a resource to multiple threads in a sequential order, and are a recommended design pattern that uses threads for most of the scenarios that require concurrency.

The Queue module provides a way to implement different kinds of queuing, such as FIFO (default implementation), LIFO queues, and priority queues, and this module comes with a built-in implementation of all the locking semantics required for running multithreaded programs.

Here's a quick roundup of the basic usage of the Queue module:

my_queue = Queue() #create empty queuemy_queue.put(data)# put items into queue ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required