The documentation says everything you need to know to answer the question (emphasis mine):

Queue.get([block[, timeout]])

Remove and return an item from the queue. If optional args block is true and timeout is None (the default), block if necessary until an item is available. If timeout is a positive number, it blocks at most timeout seconds and raises the Empty exception if no item was available within that time. Otherwise (block is false), return an item if one is immediately available, else raise the Empty exception (timeout is ignored in that case).

Answer from NPE on Stack Overflow
🌐
Python
docs.python.org › 3 › library › queue.html
queue — A synchronized queue class
February 23, 2026 - Indicate that a formerly enqueued task is complete. Used by queue consumer threads. For each get() used to fetch a task, a subsequent call to task_done() tells the queue that the processing on the task is complete.
🌐
GeeksforGeeks
geeksforgeeks.org › python › queue-in-python
Queue in Python - GeeksforGeeks
December 11, 2025 - Python’s queue module provides a thread-safe FIFO queue. You can specify a maxsize. Key Methods are: ... 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())
🌐
Python
bugs.python.org › issue23582
Issue 23582: multiprocessing.Queue.get is not getting all the items in the queue - Python tracker
This issue tracker has been migrated to GitHub, and is currently read-only. For more information, see the GitHub FAQs in the Python's Developer Guide · This issue has been migrated to GitHub: https://github.com/python/cpython/issues/67770
🌐
Python
docs.python.org › 3 › library › asyncio-queue.html
Queues — Python 3.14.4 documentation
February 22, 2026 - If immediate is false (the default), the queue can be wound down normally with get() calls to extract tasks that have already been loaded.
🌐
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 - The key classes implemented in the queue module are: ... Queue implements a basic FIFO queue. You can initialize a Queue instance like this: from queue import Queue q = Queue() # The key methods available are: qsize() # - Get ...
🌐
Great Learning
mygreatlearning.com › blog › it/software development › python queue
Python Queue
October 14, 2024 - In the above example, the get() method is used to remove the element from the queue. LIFO means the element that is entered at the last will be the first element to be popped out or deleted. To implement, LIFO, we are required to import the queue module and use LifoQueue() method in Python.
🌐
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.
Find elsewhere
🌐
Pythontic
pythontic.com › multiprocessing › queue › get
Multiprocessing.queues.queue.get | Pythontic.com
The get() method of the Queue class of Python multiprocessing library reads and removes a Python object from a multiprocessing Queue. The Python example, produces one consumer process which reads from a Queue and the parent process itself produces the Python objects for the Queue instance.
🌐
Troy Fawkes
troyfawkes.com › home › blog › the basics of python multithreading and queues
The Basics of Python Multithreading and Queues - Troy Fawkes
May 13, 2024 - It’s the bare-bones concepts of Queuing and Threading in Python. Before you do anything else, import Queue. ... my_list = [] my_list.append(1) my_list.append(2) my_list.append(3) print my_list.pop(0) # Outputs: 1 · The above code creates a list, assigns it three values, then removes the first value in so the list now has only 2 values (which are 2 and 3). my_queue = Queue(maxsize=0) my_queue.put(1) my_queue.put(2) my_queue.put(3) print my_queue.get() my_queue.task_done() # Outputs: 1
🌐
Python Module of the Week
pymotw.com › 2 › Queue
Queue – A thread-safe FIFO implementation - Python Module of the Week
It processes items in the queue one after another. These daemon threads go into an infinite loop, and only exit when the main thread ends. """ while True: print '%s: Looking for the next enclosure' % i url = q.get() print '%s: Downloading:' % i, url # instead of really downloading the URL, # we just pretend and sleep time.sleep(i + 2) q.task_done() # Set up some threads to fetch the enclosures for i in range(num_fetch_threads): worker = Thread(target=downloadEnclosures, args=(i, enclosure_queue,)) worker.setDaemon(True) worker.start() # Download the feed(s) and put the enclosure URLs into # the queue.
Top answer
1 of 3
5

I originally deleted this answer after I read @Martijn Pieters', since he decribed the "why this doesn't work" in more detail and earlier. Then I realized, that the use case in OP's example doesn't quite fit to the canonical sounding title of

"How to use multiprocessing.Queue.get method".

That's not because there's no child process involved for demonstration, but because in real applications hardly ever a queue is pre-filled and only read out after, but reading and writing happens interleaved with waiting times in between. The extended demonstration code Martijn showed, wouldn't work in the usual scenarios, because the while loop would break too soon when enqueuing doesn't keep up with reading. So here is the answer reloaded, which is able to deal with the usual interleaved feeds & reads scenarios:


Don't rely on queue.empty checks for synchronization.

After putting an object on an empty queue there may be an infinitesimal delay before the queue’s empty() method returns False and get_nowait() can return without raising queue.Empty. ...

empty()

Return True if the queue is empty, False otherwise. Because of multithreading/multiprocessing semantics, this is not reliable. docs

Either use for msg in iter(queue.get, sentinel): to .get() from the queue, where you break out of the loop by passing a sentinel value...iter(callable, sentinel)?

from multiprocessing import Queue

SENTINEL = None

if __name__ == '__main__':

    queue = Queue()

    for i in [*range(3), SENTINEL]:
        queue.put(i)

    for msg in iter(queue.get, SENTINEL):
        print(msg)

...or use get_nowait() and handle a possible queue.Empty exception if you need a non-blocking solution.

from multiprocessing import Queue
from queue import Empty
import time

SENTINEL = None

if __name__ == '__main__':

    queue = Queue()

    for i in [*range(3), SENTINEL]:
        queue.put(i)

    while True:
        try:
            msg = queue.get_nowait()
            if msg == SENTINEL:
                break
            print(msg)
        except Empty:
            # do other stuff
            time.sleep(0.1)

In case only one process and only one thread within this process is reading the queue, it would be also possible to exchange the last code snippet with:

while True:
    if not queue.empty():  # this is not an atomic operation ...
        msg = queue.get()  # ... thread could be interrupted in between
        if msg == SENTINEL:
            break
        print(msg)
    else:
        # do other stuff
        time.sleep(0.1)

Since a thread could drop the GIL in between checking if not queue.empty() and queue.get(), this wouldn't be suitable for multi-threaded queue-reads in a process. The same applies if multiple processes are reading from the queue.

For single-producer / single-consumer scenarios, using a multiprocessing.Pipe instead of multiprocessing.Queue would be sufficient and more performant, though.

2 of 3
4

Your code actually works, some of the time.

That's because the queue is not instantly not empty. The implementation is a bit more involved to support communication between multiple processes, so threads and pipes are involved that cause the empty state to last a little longer than your code allows for.

See the note in the Pipes and Queues section:

When an object is put on a queue, the object is pickled and a background thread later flushes the pickled data to an underlying pipe. This has some consequences which are a little surprising, but should not cause any practical difficulties – if they really bother you then you can instead use a queue created with a manager.

  1. After putting an object on an empty queue there may be an infinitesimal delay before the queue’s empty() method returns False [...]

(bold emphasis mine)

If you add a loop to check for emptyness first then your code works:

queue = multiprocessing.Queue()

for i in range(3):
    queue.put(i)

while queue.empty():
    print 'queue is still empty'

while not queue.empty():
    print queue.get()

When you run the above, most of the time the 'queue is still empty' appears once. Sometimes it doesn't appear at all, and sometimes it'll be printed twice.

🌐
iO Flood
ioflood.com › blog › python-queue
Python Queue Class | Usage Guide (With Examples)
February 5, 2024 - The get method is used to retrieve and remove the first item from the queue, which in this case outputs ‘item’. This is just a basic example. Stay tuned as we delve into more detailed usage and advanced techniques of Python queues.
🌐
Read the Docs
python.readthedocs.io › en › latest › library › queue.html
17.7. queue — A synchronized queue class
November 15, 2017 - Raises ShutDown if the queue has been shut down and is empty, or if the queue has been shut down immediately. ... Equivalent to get(False).
🌐
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
🌐
GitHub
github.com › python › cpython › blob › main › Lib › queue.py
cpython/Lib/queue.py at main · python/cpython
def _get(self): return self.queue.pop() · · class _PySimpleQueue: '''Simple, unbounded FIFO queue. · This pure Python implementation is not reentrant. ''' # Note: while this pure Python version provides fairness · # (by using a threading.Semaphore which is itself fair, being based ·
Author   python
🌐
Python
docs.python.org › 3.5 › library › asyncio-queue.html
18.5.8. Queues — Python 3.5.10 documentation
December 18, 2020 - Used by queue consumers. For each get() used to fetch a task, a subsequent call to task_done() tells the queue that the processing on the task is complete.
🌐
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.
🌐
Intellipaat
intellipaat.com › home › blog › queue in python – implementation explained
Queue in Python: How to Implement Queue in Python
October 14, 2025 - Let’s understand how to add or remove items from a LIFO queue. To add items in a queue, put() function is used. Let’s see an example below: ... Code Copied! ... To remove an element from the queue, get() function is used.