DelayQueue in Python

Photo by Anne Nygård on Unsplash

Queue in Python:

Most of the programming languages offer this queue implementation as its core part as its essential in many use cases.

  1. LIFO Queue (Last In First Out)
  2. PriorityQueue
  3. SimpleQueue (also known as Unbounded FIFO Queue)
from queue import Queue as FifoQueuefifo_queue = FifoQueue()
fifo_queue.put("an item")
fifo_queue.get() # returns "an item" from queue


DelayQueue is a specialized Priority Queue that orders elements based on their delay time. It means only elements whose time has expired can be taken from the queue. DelayQueue head contains the element that has expired/going to expire in the least time.

DelayQueue in Python:

The queue library in python doesn’t speak about delay queue and the PyPI search shows that there is only one delay queue implementation which also mentions that the project is in the beta stage and has not been updated for almost 6years. Though the code works, the queue.get will return immediately with an item from the queue or with an exception. It is up to the developer to handle these cases.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Yogaraj Sivaprakasam

Yogaraj Sivaprakasam

Developer for fun | Python | Vue.js | Linux monitoring | Frameworks