Python
docs.python.org › 3 › library › queue.html
queue — A synchronized queue class
February 23, 2026 - Source code: Lib/queue.py The queue module implements multi-producer, multi-consumer queues. It is especially useful in threaded programming when information must be exchanged safely between multip...
Real Python
realpython.com › ref › stdlib › queue
queue | Python Standard Library – Real Python
import logging import queue import threading import time logging.basicConfig(level=logging.INFO, format="%(threadName)s %(message)s") def worker(tasks): while True: task = tasks.get() if task is None: tasks.task_done() break logging.info(f"processing {task}") time.sleep(1) tasks.task_done() tasks = queue.Queue() for task in ["task1", "task2", "task3", "task4", "task5"]: tasks.put(task) num_workers = 2 for _ in range(num_workers): tasks.put(None) threads = [ threading.Thread(target=worker, args=(tasks,)) for _ in range(num_workers) ] for thread in threads: thread.start() tasks.join() for thread in threads: thread.join() # Output: # Thread-1 (worker) processing task1 # Thread-2 (worker) processing task2 # Thread-1 (worker) processing task3 # Thread-2 (worker) processing task4 # Thread-1 (worker) processing task5
Videos
18:47
Queues in Python Explained [ Step-by-Step Guide to Data Structures ...
Python QUEUEs | Queue implementation example
16:19
Queue - Data Structures in Python #3 - YouTube
Python Queue
26:12
Working with Queues in Python - An introductory guide - YouTube
11:00
Python Intermediate Tutorial #6 - Queues - YouTube
W3Schools
w3schools.com › python › python_dsa_queues.asp
Queues with Python
Queues are often mentioned together with Stacks, which is a similar data structure described on the previous page. For Python lists (and arrays), a Queue can look and behave like this:
W3Schools
w3schools.com › python › ref_module_queue.asp
Python queue Module
Python Examples Python Compiler Python Exercises Python Quiz Python Challenges Python Practice Problems Python Server Python Syllabus Python Study Plan Python Interview Q&A Python Bootcamp Python Certificate Python Training · ❮ Standard Library Modules · Create a FIFO queue, put an item, then get it back: import queue q = queue.Queue() q.put('task1') print(q.get()) Try it Yourself » ·
Real Python
realpython.com › queue-in-python
Python Stacks, Queues, and Priority Queues in Practice – Real Python
December 1, 2023 - To get the most out of this tutorial, you should be familiar with Python’s sequence types, such as lists and tuples, and the higher-level collections in the standard library. You can download the complete source code for this tutorial with the associated sample data by clicking the link in the box below: Get Source Code: Click here to get access to the source code and sample data that you’ll use to explore queues in Python.
RQ
python-rq.org
RQ: Simple job queues for Python
from rq.repeat import Repeat # Repeat job 3 times after successful completion, with 60 second intervals job = queue.enqueue(say_hello, repeat=Repeat(times=3, interval=60)) # Use different intervals between repetitions job = queue.enqueue(say_hello, repeat=Repeat(times=3, interval=[10, 30, 60]))
Simplilearn
simplilearn.com › home › resources › software development › queue in python: working with queue data structure in python
Queue in Python: Working With Queue Data Structure in Python
March 5, 2026 - A queue is a built-in module of python used in threaded programming. It stores items sequentially in a FIFO manner. Learn all about the queue in python now!
Address 5851 Legacy Circle, 6th Floor, Plano, TX 75024 United States
Runestone Academy
runestone.academy › ns › books › published › pythonds › BasicDS › ImplementingaQueueinPython.html
4.12. Implementing a Queue in Python — Problem Solving with Algorithms and Data Structures
CodeLens 1 shows the Queue class in action as we perform the sequence of operations from Table 1. Activity: CodeLens Example Queue Operations (ququeuetest)
O'Reilly
oreilly.com › library › view › python-standard-library › 0596000960 › ch03s03.html
The Queue Module - Python Standard Library [Book]
May 10, 2001 - File: queue-example-1.py import threading import Queue import time, random WORKERS = 2 class Worker(threading.Thread): def _ _init_ _(self, queue): self._ _queue = queue threading.Thread._ _init_ _(self) def run(self): while 1: item = self._ _queue.get() if item is None: break # reached end of queue # pretend we're doing something that takes 10—100 ms time.sleep(random.randint(10, 100) / 1000.0) print "task", item, "finished" # # try it queue = Queue.Queue(0) for i in range(WORKERS): Worker(queue).start() # start a worker for i in range(10): queue.put(i) for i in range(WORKERS): queue.put(None) # add end-of-queue markers task 1 finished task 0 finished task 3 finished task 2 finished task 4 finished task 5 finished task 7 finished task 6 finished task 9 finished task 8 finished
Author Fredrik Lundh
Published 2001
Pages 304
Read the Docs
python.readthedocs.io › en › latest › library › queue.html
17.7. queue — A synchronized queue class
November 15, 2017 - Source code: Lib/queue.py The queue module implements multi-producer, multi-consumer queues. It is especially useful in threaded programming when information must be exchanged safely between multip...
GitHub
github.com › rq › rq
GitHub - rq/rq: Simple job queues for Python · GitHub
from rq import cron from myapp import send_newsletter, backup_database # Database backup every day at 3:00 AM cron.register( backup_database, queue_name='maintenance', cron_string='0 3 * * *' ) # Monthly report on the first day of each month at 8:00 AM cron.register( generate_monthly_report, queue_name='reports', cron_string='0 8 1 * *' ) ```python More details on functionality can be found in the [docs](https://python-rq.org/docs/cron/).
Starred by 10.6K users
Forked by 1.5K users
Languages Python
Python
docs.python.org › 3.5 › library › asyncio-queue.html
18.5.8. Queues — Python 3.5.10 documentation
December 18, 2020 - If it is an integer greater than 0, then yield from put() will block when the queue reaches maxsize, until an item is removed by get(). Unlike the standard library queue, you can reliably know this Queue’s size with qsize(), since your single-threaded asyncio application won’t be interrupted between calling qsize() and doing an operation on the Queue.
Python Module of the Week
pymotw.com › 2 › Queue
Queue – A thread-safe FIFO implementation - Python Module of the Week
In this single-threaded example, the jobs are pulled out of the queue in strictly priority order. If there were multiple threads consuming the jobs, they would be processed based on the priority of items in the queue at the time get() was called. $ python Queue_priority.py New job: Mid-level ...