Using the built-in map function :

map(q.put, items)

It will apply q.put to all your items in your list. Useful one-liner.


For Python 3, you can use it as following :

list(map(q.put, items))

Or also :

from collections import deque
deque(map(q.put, items))

But at this point, the for loop is quite more readable.

Answer from FunkySayu on Stack Overflow
🌐
Python
docs.python.org › 3 › library › queue.html
queue — A synchronized queue class
February 23, 2026 - 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). ... Equivalent to get(False).
Discussions

How do I pop multiple items from a queue? (python)
filter(lambda x: x < 50, xs) where xs is your collection of numbers. Documentation . More on reddit.com
🌐 r/CodingHelp
3
1
October 9, 2022
How to iterate Queue.Queue items in Python? - Stack Overflow
Does anyone know a pythonic way of iterating over the elements of a Queue.Queue without removing them from the Queue. I have a producer/consumer-type program where items to be processed are passed by More on stackoverflow.com
🌐 stackoverflow.com
python - Get all items from thread Queue - Stack Overflow
5 Run multiple functions every second, write result to file · 4 Python Queue waiting for thread before getting next item More on stackoverflow.com
🌐 stackoverflow.com
Multiprocess.Queue only get some of items not all
I’m using multiprocessing.Process to build a master and worker system. The master is coordinating between the worker and the workers send information to the master by the master_event_queue, and the master send information to workers by worker_event queue. The code looks like this: class ... More on discuss.python.org
🌐 discuss.python.org
2
0
March 19, 2024
🌐
Bobby Hadz
bobbyhadz.com › blog › python-queue-get-item-without-removing-it
Getting Queue elements and iterating over a Queue in Python | bobbyhadz
April 8, 2024 - Use the `queue` attribute on the queue to get an item from a queue without removing it, e.g. `q.queue[0]`.
🌐
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 Queue class provided by the queue module can be used for safely exchanging objects between multiple threads or processes. This allows you to build multi-producer, multi-consumer queues in Python.
🌐
GeeksforGeeks
geeksforgeeks.org › queue-in-python
Queue in Python - GeeksforGeeks
July 9, 2024 - If queue is empty, wait until an item is available. get_nowait() – Return an item if one is immediately available, else raise QueueEmpty.
🌐
GitHub
github.com › python-trio › trio › issues › 562
Get N items from Channel · Issue #562 · python-trio/trio
It would be super useful to be able to get multiple items from a trio.Queue object at once, ideally with a few options to tune if you want to get exactly N items (and block until N items happen), o...
Find elsewhere
🌐
CopyProgramming
copyprogramming.com › howto › python-python-queue-queue-get-multiple-items
Python Queue: Getting Multiple Items, 2026 Features & Best Practices - Python queue getting multiple items
November 15, 2025 - While Python doesn't provide a built-in method to retrieve multiple items from a queue in a single operation, developers can implement batch retrieval patterns, leverage the newer concurrent.interpreters.Queue for inter-process communication, or use collections.deque for simpler use cases.
Top answer
1 of 6
23

If you're always pulling all available items off the queue, is there any real point in using a queue, rather than just a list with a lock? ie:

from __future__ import with_statement
import threading

class ItemStore(object):
    def __init__(self):
        self.lock = threading.Lock()
        self.items = []

    def add(self, item):
        with self.lock:
            self.items.append(item)

    def getAll(self):
        with self.lock:
            items, self.items = self.items, []
        return items

If you're also pulling them individually, and making use of the blocking behaviour for empty queues, then you should use Queue, but your use case looks much simpler, and might be better served by the above approach.

[Edit2] I'd missed the fact that you're polling the queue from an idle loop, and from your update, I see that the problem isn't related to contention, so the below approach isn't really relevant to your problem. I've left it in in case anyone finds a blocking variant of this useful:

For cases where you do want to block until you get at least one result, you can modify the above code to wait for data to become available through being signalled by the producer thread. Eg.

class ItemStore(object):
    def __init__(self):
        self.cond = threading.Condition()
        self.items = []

    def add(self, item):
        with self.cond:
            self.items.append(item)
            self.cond.notify() # Wake 1 thread waiting on cond (if any)

    def getAll(self, blocking=False):
        with self.cond:
            # If blocking is true, always return at least 1 item
            while blocking and len(self.items) == 0:
                self.cond.wait()
            items, self.items = self.items, []
        return items
2 of 6
19

I think the easiest way of getting all items out of the queue is the following:

def get_all_queue_result(queue):

    result_list = []
    while not queue.empty():
        result_list.append(queue.get())

    return result_list
🌐
GitHub
github.com › leio10 › python-multiqueue
GitHub - leio10/python-multiqueue: Sometimes when you use the Queue class in Python, you need to get an item from any of several queues. This small module implements an easy solution for this problem.
If you have 2 queues in a MultiQueue, with weights 1 and 10 and both with a large number of elements, in 11 calls to get method you will obtain just one element from the first queue and 10 elements from the second. A disadvantage of the approach used is that it is not possible to ask for items from a specific queue.
Author   leio10
🌐
Super Fast Python
superfastpython.com › multiprocessing-queue-in-python
Multiprocessing Queue in Python – SuperFastPython
May 27, 2022 - ... # get the next value item = queue.get() # check if no further values are expected if item is None: # terminate the process return · If there are multiple consumers that need to get the message, then a consumer may get the None item, and re-add it for other consumers to consume and respond to.
🌐
Python.org
discuss.python.org › python help
Multiprocess.Queue only get some of items not all - Python Help - Discussions on Python.org
March 19, 2024 - I’m using multiprocessing.Process to build a master and worker system. The master is coordinating between the worker and the workers send information to the master by the master_event_queue, and the master send information to workers by worker_event queue. The code looks like this: class ...
🌐
Great Learning
mygreatlearning.com › blog › it/software development › python queue
Python Queue
October 14, 2024 - In this article, we have seen how we can add a single item or element to our queue. Now, let us see how we can add more than one element in Python:
🌐
Python
docs.python.org › 3 › library › asyncio-queue.html
Queues — Python 3.14.4 documentation
February 22, 2026 - Return the number of items in the queue. ... Put a Queue instance into a shutdown mode. The queue can no longer grow. Future calls to put() raise QueueShutDown. Currently blocked callers of put() will be unblocked and will raise QueueShutDown in the formerly awaiting task. If immediate is false (the default), the queue can be wound down normally with get() calls to extract tasks that have already been loaded.
🌐
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
🌐
Stack Overflow
stackoverflow.com › questions › 33420727 › python-processing-multiple-items-in-queue-using-workers
Python processing multiple items in queue using workers - Stack Overflow
I want each process to process different website but for some reason the processes runs multiple times and never exits. from multiprocessing import Process import Queue import requests def readdata(item): print item r = requests.get(item) print 'read data' print r.status_code def worker(queue): while True: try: print 'start process' item = queue.get() readdata(item) q.task_done() except: print "the end" break if __name__ == "__main__": nthreads = 4 queue = Queue.Queue() # put stuff in the queue here moreStuff = ['http://www.google.com','http://www.yahoo.com','http://www.cnn.com'] for stuff in moreStuff: queue.put(stuff) procs = [Process(target = worker, args = (queue,)) for i in xrange(nthreads)] for p in procs: p.start() for p in procs: p.join()
🌐
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.