Skip to content
Collection of persistent (disk-based) queues
Branch: master
Clone or download

Latest commit


Type Name Latest commit message Commit time
Failed to load latest commit information.
queuelib rename Queue -> RRQueue Mar 1, 2018
.bumpversion.cfg Bump version: 1.4.2 → 1.5.0 Mar 12, 2018
.coveragerc Add coverage report Aug 14, 2015
.travis.yml Tune environments tested under travis-ci Mar 8, 2018
LICENSE initial commit Apr 23, 2013
MANIFEST initial commit Apr 23, 2013 initial commit Apr 23, 2013
NEWS initial commit Apr 23, 2013
README.rst Tweak README Feb 25, 2018
setup.cfg fix publishing to pypi and use universal wheels Jul 25, 2014 Bump version: 1.4.2 → 1.5.0 Mar 12, 2018
tox.ini Tune environments tested under travis-ci Mar 8, 2018


queuelib Coverage report

Queuelib is a collection of persistent (disk-based) queues for Python.

Queuelib goals are speed and simplicity. It was originally part of the Scrapy framework and stripped out on its own library.

Note: Queuelib isn't thread-safe.


  • Python 2.7 or Python 3.3
  • no external library requirements


You can install Queuelib either via the Python Package Index (PyPI) or from source.

To install using pip:

$ pip install queuelib

To install using easy_install:

$ easy_install queuelib

If you have downloaded a source tarball you can install it by running the following (as root):

# python install

FIFO/LIFO disk queues

Queuelib provides FIFO and LIFO queue implementations.

Here is an example usage of the FIFO queue:

>>> from queuelib import FifoDiskQueue
>>> q = FifoDiskQueue("queuefile")
>>> q.push(b'a')
>>> q.push(b'b')
>>> q.push(b'c')
>>> q.pop()
>>> q.close()
>>> q = FifoDiskQueue("queuefile")
>>> q.pop()
>>> q.pop()
>>> q.pop()

The LIFO queue is identical (API-wise), but importing LifoDiskQueue instead.


A discrete-priority queue implemented by combining multiple FIFO/LIFO queues (one per priority).

First, select the type of queue to be used per priority (FIFO or LIFO):

>>> from queuelib import FifoDiskQueue
>>> qfactory = lambda priority: FifoDiskQueue('queue-dir-%s' % priority)

Then instantiate the Priority Queue with it:

>>> from queuelib import PriorityQueue
>>> pq = PriorityQueue(qfactory)

And use it:

>>> pq.push(b'a', 3)
>>> pq.push(b'b', 1)
>>> pq.push(b'c', 2)
>>> pq.push(b'd', 2)
>>> pq.pop()
>>> pq.pop()
>>> pq.pop()
>>> pq.pop()


Has nearly the same interface and implementation as a Priority Queue except that each element must be pushed with a (mandatory) key. Popping from the queue cycles through the keys "round robin".

Instantiate the Round Robin Queue similarly to the Priority Queue:

>>> from queuelib import RoundRobinQueue
>>> rr = RoundRobinQueue(qfactory)

And use it:

>>> rr.push(b'a', '1')
>>> rr.push(b'b', '1')
>>> rr.push(b'c', '2')
>>> rr.push(b'd', '2')
>>> rr.pop()
>>> rr.pop()
>>> rr.pop()
>>> rr.pop()

Mailing list

Use the scrapy-users mailing list for questions about Queuelib.

Bug tracker

If you have any suggestions, bug reports or annoyances please report them to our issue tracker at:


Development of Queuelib happens at GitHub:

You are highly encouraged to participate in the development. If you don't like GitHub (for some reason) you're welcome to send regular patches.

All changes require tests to be merged.


Tests are located in queuelib/tests directory. They can be run using nosetests with the following command:


The output should be something like the following:

$ nosetests
Ran 77 tests in 0.145s



This software is licensed under the BSD License. See the LICENSE file in the top distribution directory for the full license text.


This software follows Semantic Versioning

You can’t perform that action at this time.