You do

from queue import *

This imports all the classes from the queue module already. Change that line to

q = Queue(maxsize=0)

CAREFUL: "Wildcard imports (from import *) should be avoided, as they make it unclear which names are present in the namespace, confusing both readers and many automated tools". (Python PEP-8)

As an alternative, one could use:

from queue import Queue

q = Queue(maxsize=0)
Answer from David Robinson on Stack Overflow
🌐
Python
docs.python.org › 3 › library › queue.html
queue — A synchronized queue class
February 23, 2026 - Example of how to wait for enqueued tasks to be completed: import threading import queue q = queue.Queue() def worker(): while True: item = q.get() print(f'Working on {item}') print(f'Finished {item}') q.task_done() # Turn-on the worker thread.
🌐
GeeksforGeeks
geeksforgeeks.org › python › queue-in-python
Queue in Python - GeeksforGeeks
December 11, 2025 - Python · from queue import Queue q = Queue(maxsize=3) print("Initial size:", q.qsize()) q.put('a') q.put('b') q.put('c') print("Is full:", q.full()) print("Elements dequeued from the queue:") print(q.get()) print(q.get()) print(q.get()) print("Is empty:", q.empty()) q.put(1) print("Is empty:", q.empty()) print("Is full:", q.full()) Output ·
🌐
Medium
basillica.medium.com › working-with-queues-in-python-a-complete-guide-aa112d310542
Working with Queues in Python — A Complete Guide | by Basillica | Medium
March 27, 2024 - You can initialize a Queue instance like this: from queue import Queue q = Queue() # The key methods available are: qsize() # - Get the size of the queue empty() # - Check if queue is empty full() # - Check if queue is full put(item) # - Put ...
🌐
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 › ref › stdlib › queue
queue | Python Standard Library – Real Python
The Python queue module provides reliable thread-safe implementations of the queue data structure. It is commonly used for task scheduling and managing work between multiple threads. Here’s a quick example: Python · >>> import queue >>> tasks = queue.Queue() >>> tasks.put("task1") >>> tasks.put("task2") >>> tasks.get() 'task1' >>> tasks.get() 'task2' Provides thread-safe FIFO, LIFO, and priority queues ·
🌐
GeeksforGeeks
geeksforgeeks.org › dsa › stack-queue-python-using-module-queue
Stack and Queue in Python using queue Module - GeeksforGeeks
August 1, 2022 - When we try to add data into a Queue above is maxsize, it is called OverFlow(Queue Full) and when we try removing an element from an empty, it's called Underflow. put() and get() do not give error upon Underflow and Overflow, but goes into an infinite loop. Implementation: python3 · import queue L = queue.Queue(maxsize=6) # qsize() give the maxsize # of the Queue print(L.qsize()) L.put(5) L.put(9) L.put(1) L.put(7) # Return Boolean for Full # Queue print("Full: ", L.full()) L.put(9) L.put(10) print("Full: ", L.full()) print(L.get()) print(L.get()) print(L.get()) # Return Boolean for Empty # Queue print("Empty: ", L.empty()) print(L.get()) print(L.get()) print(L.get()) print("Empty: ", L.empty()) print("Full: ", L.full()) # This would result into Infinite # Loop as the Queue is empty.
Find elsewhere
🌐
Python
docs.python.org › 3 › library › asyncio-queue.html
Queues — Python 3.14.4 documentation
February 22, 2026 - Queues can be used to distribute workload between several concurrent tasks: import asyncio import random import time async def worker(name, queue): while True: # Get a "work item" out of the queue. sleep_for = await queue.get() # Sleep for the ...
🌐
Python Module of the Week
pymotw.com › 2 › Queue
Queue – A thread-safe FIFO implementation - Python Module of the Week
import Queue class Job(object): def __init__(self, priority, description): self.priority = priority self.description = description print 'New job:', description return def __cmp__(self, other): return cmp(self.priority, other.priority) q = Queue.PriorityQueue() q.put( Job(3, 'Mid-level job') ) q.put( Job(10, 'Low-level job') ) q.put( Job(1, 'Important job') ) while not q.empty(): next_job = q.get() print 'Processing job:', next_job.description · 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 job New job: Low-level job New job: Important job Processing job: Important job Processing job: Mid-level job Processing job: Low-level job
🌐
Great Learning
mygreatlearning.com › blog › it/software development › python queue
Python Queue
October 14, 2024 - FIFO means the element that is inserted first will be the first element to be removed from the list. To implement the FIFO queue, we are required to import the queue() module in Python.
🌐
PyPI
pypi.org › project › queuelib
queuelib
JavaScript is disabled in your browser. Please enable JavaScript to proceed · A required part of this site couldn’t load. This may be due to a browser extension, network issues, or browser settings. Please check your connection, disable any ad blockers, or try using a different browser
🌐
Python
docs.python.org › fr › 3 › library › queue.html
queue --- A synchronized queue class — Documentation Python 3.14.4
February 21, 2026 - The count of unfinished tasks goes up whenever an item is added to the queue. The count goes down whenever a consumer thread calls task_done() to indicate that the item was retrieved and all work on it is complete. When the count of unfinished tasks drops to zero, join() unblocks. Exemple montrant comment attendre que les tâches mises dans la file soient terminées : import threading import queue q = queue.Queue() def worker(): while True: item = q.get() print(f'Working on {item}') print(f'Finished {item}') q.task_done() # Turn-on the worker thread.
🌐
Faucet
docs.faucet.nz › en › 1.6.15 › _modules › queue.html
queue — Python documentation
'''A multi-producer, multi-consumer queue.''' try: import threading except ImportError: import dummy_threading as threading from collections import deque from heapq import heappush, heappop from time import monotonic as time __all__ = ['Empty', 'Full', 'Queue', 'PriorityQueue', 'LifoQueue'] ...
🌐
AskPython
askpython.com › home › python queue module
Python Queue Module - AskPython
February 26, 2020 - In Python, we can use the queue module to create a queue of objects. This is a part of the standard Python library, so there’s no need to use pip. Import the module using: import queue ·
🌐
O'Reilly
oreilly.com › library › view › python-standard-library › 0596000960 › ch03s03.html
The Queue Module - Python Standard Library [Book]
May 10, 2001 - The Queue module provides a thread-safe queue implementation, shown in Example 3-2. It provides a convenient way of moving Python objects between different threads. Example 3-2. Using the Queue Module · 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) / 100
Author   Fredrik Lundh
Published   2001
Pages   304
🌐
Python
docs.python.org › 3 › library › multiprocessing.html
multiprocessing — Process-based parallelism
February 23, 2026 - Local processes can also access that queue, using the code from above on the client to access it remotely: >>> from multiprocessing import Process, Queue >>> from multiprocessing.managers import BaseManager >>> class Worker(Process): ... def ...
🌐
Nitric Docs
nitric.io › docs › reference › python › queues › queue
Python: queue() | Nitric Documentation
This is reference documentation for the Nitric Python SDK. To learn about Queues in Nitric start with the Async Messaging docs. Creates a new Queue to process asynchronous messages. CopyCopied · from nitric.resources import queue · from nitric.application import Nitric ·
🌐
Microsoft Learn
learn.microsoft.com › en-us › azure › storage › queues › storage-quickstart-queues-python
Quickstart: Azure Queue Storage client library for Python - Azure Storage | Microsoft Learn
June 29, 2023 - From the project directory, install the Azure Queue Storage client library for Python package by using the pip install command. The azure-identity package is needed for passwordless connections to Azure services.
🌐
Reddit
reddit.com › r/renpy › why can't i import queue? - no module named queue
r/RenPy on Reddit: Why can't I import queue? - No module named queue
September 26, 2021 -

I know this is probably a dumb question, but I don't seem to be able to import queue. Does it have anything to do with "queue" going orange when you write it? Or does it have something to do with the python version? I don't have a problem importing other stuff.

🌐
DaniWeb
daniweb.com › programming › software-development › threads › 251918 › import-queue-dont-exist
python - Import queue dont exist? [SOLVED] | DaniWeb
January 10, 2010 - You can also print the search path to verify where Python is looking: import sys; print(sys.path). For code that works on both 2.x and 3.x, use a compatibility import and then reference the module consistently: try: import queue # Python 3 except ImportError: import Queue as queue # Python 2 q = queue.Queue() # maxsize is optional; omit or use 0 for unbounded q.put("item") item = q.get() q.task_done() # no arguments; call once per processed item