In the post FIFO and LIFO queues in python I shown how to use queues in python 3.
Python provides also priority queues.

You can use such a queue when the processing order of the items in a queue needs to be based on the importance of the items.
In a priority queue, the most important element will always be popped first, so in a priority queue you have to push a tuple of at least two elements: the priority and the content. The element with the lowest value for the priority will be popped.

The following program populates a priority queue with random priority values and some text.

then it pops data from the priority queue and prints out the popped items

You can find the full source code with the latest updates on my github:

When you run the program it will ouput something like the following

as you can see, it pushes data with random priority. And, then:

it pops data starting with lowest priorities.