counter = itertools.count()
for i in range(10):
    heapq.heappush(heap, (i, -next(counter), str(i) + ' oldest'))
heapq.heappush(heap, (i, -next(counter), str(i) + ' newest'))
heapq.heappop(heap)
heapq.heappop(heap)
heapq.heappop(heap)
heapq.heappop(heap)
Разрыв связи в очереди приоритетов с использованием python