Search code examples
pythonpython-3.xqueuepriority-queuepeek

Can I get an item from a PriorityQueue without removing it yet?


I want to get the next item in queue but I don't want to dequeue it. Is it possible in Python's queue.PriorityQueue? From the docs, I don't see how can it be done


Solution

  • When you get item form the queue as per theory it will remove from the queue. You have to write your own function which will give you last element of PriorityQueue. You can create a peek function by inherit the priorityqueue.