Skip to main content

Collection of persistent (disk-based) queues

Project description

https://secure.travis-ci.org/scrapy/queuelib.png?branch=master 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.

Requirements

  • Python 2.7 or Python 3.3

  • no external library requirements

Installation

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 setup.py 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()
b'a'
>>> q.close()
>>> q = FifoDiskQueue("queuefile")
>>> q.pop()
b'b'
>>> q.pop()
b'c'
>>> q.pop()
>>>

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

PriorityQueue

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()
b'b'
>>> pq.pop()
b'c'
>>> pq.pop()
b'd'
>>> pq.pop()
b'a'

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: http://github.com/scrapy/queuelib/issues/

Contributing

Development of Queuelib happens at GitHub: http://github.com/scrapy/queuelib

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

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

nosetests

The output should be something like the following:

$ nosetests
.............................................................................
----------------------------------------------------------------------
Ran 77 tests in 0.145s

OK

License

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

Versioning

This software follows Semantic Versioning

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

queuelib-1.3.0.tar.gz (7.2 kB view details)

Uploaded Source

Built Distribution

queuelib-1.3.0-py2.py3-none-any.whl (9.7 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file queuelib-1.3.0.tar.gz.

File metadata

  • Download URL: queuelib-1.3.0.tar.gz
  • Upload date:
  • Size: 7.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for queuelib-1.3.0.tar.gz
Algorithm Hash digest
SHA256 f7a2182c9d493bceee0985636891f92369fcc4575edcc055e16cb63b393e210c
MD5 9f27ba65af6eaa43e6c6e3a952231628
BLAKE2b-256 1df88f6fd46e1158e444b7843d63f7e40d8bee92810e42ac9f8798f8bdb4cb68

See more details on using hashes here.

Provenance

File details

Details for the file queuelib-1.3.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for queuelib-1.3.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 2024f928a9e4e880d7b6da6578d09f7be208cff8227959677f6c92873b0b69c9
MD5 8730dfe4668404f352d5f765b6d2023d
BLAKE2b-256 dc0dbc6352e13fb500434b9ec210f670eccc32d0fc3d243fc12723bdae2d131e

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page