queuelib


Namequeuelib JSON
Version 1.7.0 PyPI version JSON
download
home_pagehttps://github.com/scrapy/queuelib
SummaryCollection of persistent (disk-based) and non-persistent (memory-based) queues
upload_time2024-05-04 06:02:58
maintainerNone
docs_urlNone
authorScrapy project
requires_python>=3.8
licenseBSD
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage
            ========
queuelib
========

.. image:: https://img.shields.io/pypi/v/queuelib.svg
   :target: https://pypi.python.org/pypi/queuelib

.. image:: https://img.shields.io/pypi/pyversions/queuelib.svg
   :target: https://pypi.python.org/pypi/queuelib

.. image:: https://github.com/scrapy/queuelib/actions/workflows/tests.yml/badge.svg
   :target: https://github.com/scrapy/queuelib/actions/workflows/tests.yml

.. image:: https://img.shields.io/codecov/c/github/scrapy/queuelib/master.svg
   :target: http://codecov.io/github/scrapy/queuelib?branch=master
   :alt: Coverage report


Queuelib is a Python library that implements object collections which are stored
in memory or persisted to disk, provide a simple API, and run fast.

Queuelib provides collections for queues_ (FIFO), stacks_ (LIFO), queues
sorted by priority and queues that are emptied in a round-robin_ fashion.

.. note:: Queuelib collections are not thread-safe.

Queuelib supports Python 3.5+ and has no dependencies.

.. _queues: https://en.wikipedia.org/wiki/FIFO_(computing_and_electronics)
.. _round-robin: https://en.wikipedia.org/wiki/Round-robin_scheduling
.. _stacks: https://en.wikipedia.org/wiki/Stack_(abstract_data_type)

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'

RoundRobinQueue
===============

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


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`_

.. _Scrapy framework: http://scrapy.org
.. _scrapy-users: http://groups.google.com/group/scrapy-users
.. _Semantic Versioning: http://semver.org/
.. _nosetests: https://nose.readthedocs.org/en/latest/

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/scrapy/queuelib",
    "name": "queuelib",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": null,
    "author": "Scrapy project",
    "author_email": "info@scrapy.org",
    "download_url": "https://files.pythonhosted.org/packages/fb/a4/8af5d8ee3526c64a152549a1c7b42896be9fae9a2fda7712883dc09822ac/queuelib-1.7.0.tar.gz",
    "platform": "Any",
    "description": "========\nqueuelib\n========\n\n.. image:: https://img.shields.io/pypi/v/queuelib.svg\n   :target: https://pypi.python.org/pypi/queuelib\n\n.. image:: https://img.shields.io/pypi/pyversions/queuelib.svg\n   :target: https://pypi.python.org/pypi/queuelib\n\n.. image:: https://github.com/scrapy/queuelib/actions/workflows/tests.yml/badge.svg\n   :target: https://github.com/scrapy/queuelib/actions/workflows/tests.yml\n\n.. image:: https://img.shields.io/codecov/c/github/scrapy/queuelib/master.svg\n   :target: http://codecov.io/github/scrapy/queuelib?branch=master\n   :alt: Coverage report\n\n\nQueuelib is a Python library that implements object collections which are stored\nin memory or persisted to disk, provide a simple API, and run fast.\n\nQueuelib provides collections for queues_ (FIFO), stacks_ (LIFO), queues\nsorted by priority and queues that are emptied in a round-robin_ fashion.\n\n.. note:: Queuelib collections are not thread-safe.\n\nQueuelib supports Python 3.5+ and has no dependencies.\n\n.. _queues: https://en.wikipedia.org/wiki/FIFO_(computing_and_electronics)\n.. _round-robin: https://en.wikipedia.org/wiki/Round-robin_scheduling\n.. _stacks: https://en.wikipedia.org/wiki/Stack_(abstract_data_type)\n\nInstallation\n============\n\nYou can install Queuelib either via the Python Package Index (PyPI) or from\nsource.\n\nTo install using pip::\n\n    $ pip install queuelib\n\nTo install using easy_install::\n\n    $ easy_install queuelib\n\nIf you have downloaded a source tarball you can install it by running the\nfollowing (as root)::\n\n    # python setup.py install\n\nFIFO/LIFO disk queues\n=====================\n\nQueuelib provides FIFO and LIFO queue implementations.\n\nHere is an example usage of the FIFO queue::\n\n    >>> from queuelib import FifoDiskQueue\n    >>> q = FifoDiskQueue(\"queuefile\")\n    >>> q.push(b'a')\n    >>> q.push(b'b')\n    >>> q.push(b'c')\n    >>> q.pop()\n    b'a'\n    >>> q.close()\n    >>> q = FifoDiskQueue(\"queuefile\")\n    >>> q.pop()\n    b'b'\n    >>> q.pop()\n    b'c'\n    >>> q.pop()\n    >>>\n\nThe LIFO queue is identical (API-wise), but importing ``LifoDiskQueue``\ninstead.\n\nPriorityQueue\n=============\n\nA discrete-priority queue implemented by combining multiple FIFO/LIFO queues\n(one per priority).\n\nFirst, select the type of queue to be used per priority (FIFO or LIFO)::\n\n    >>> from queuelib import FifoDiskQueue\n    >>> qfactory = lambda priority: FifoDiskQueue('queue-dir-%s' % priority)\n\nThen instantiate the Priority Queue with it::\n\n    >>> from queuelib import PriorityQueue\n    >>> pq = PriorityQueue(qfactory)\n\nAnd use it::\n\n    >>> pq.push(b'a', 3)\n    >>> pq.push(b'b', 1)\n    >>> pq.push(b'c', 2)\n    >>> pq.push(b'd', 2)\n    >>> pq.pop()\n    b'b'\n    >>> pq.pop()\n    b'c'\n    >>> pq.pop()\n    b'd'\n    >>> pq.pop()\n    b'a'\n\nRoundRobinQueue\n===============\n\nHas nearly the same interface and implementation as a Priority Queue except\nthat each element must be pushed with a (mandatory) key.  Popping from the\nqueue cycles through the keys \"round robin\".\n\nInstantiate the Round Robin Queue similarly to the Priority Queue::\n\n    >>> from queuelib import RoundRobinQueue\n    >>> rr = RoundRobinQueue(qfactory)\n\nAnd use it::\n\n    >>> rr.push(b'a', '1')\n    >>> rr.push(b'b', '1')\n    >>> rr.push(b'c', '2')\n    >>> rr.push(b'd', '2')\n    >>> rr.pop()\n    b'a'\n    >>> rr.pop()\n    b'c'\n    >>> rr.pop()\n    b'b'\n    >>> rr.pop()\n    b'd'\n\n\nMailing list\n============\n\nUse the `scrapy-users`_ mailing list for questions about Queuelib.\n\nBug tracker\n===========\n\nIf you have any suggestions, bug reports or annoyances please report them to\nour issue tracker at: http://github.com/scrapy/queuelib/issues/\n\nContributing\n============\n\nDevelopment of Queuelib happens at GitHub: http://github.com/scrapy/queuelib\n\nYou are highly encouraged to participate in the development. If you don't like\nGitHub (for some reason) you're welcome to send regular patches.\n\nAll changes require tests to be merged.\n\nTests\n=====\n\nTests are located in `queuelib/tests` directory. They can be run using\n`nosetests`_ with the following command::\n\n    nosetests\n\nThe output should be something like the following::\n\n    $ nosetests\n    .............................................................................\n    ----------------------------------------------------------------------\n    Ran 77 tests in 0.145s\n\n    OK\n\nLicense\n=======\n\nThis software is licensed under the BSD License. See the LICENSE file in the\ntop distribution directory for the full license text.\n\nVersioning\n==========\n\nThis software follows `Semantic Versioning`_\n\n.. _Scrapy framework: http://scrapy.org\n.. _scrapy-users: http://groups.google.com/group/scrapy-users\n.. _Semantic Versioning: http://semver.org/\n.. _nosetests: https://nose.readthedocs.org/en/latest/\n",
    "bugtrack_url": null,
    "license": "BSD",
    "summary": "Collection of persistent (disk-based) and non-persistent (memory-based) queues",
    "version": "1.7.0",
    "project_urls": {
        "Homepage": "https://github.com/scrapy/queuelib"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "33c863acda77e8b3babed827d868eb04efecb3b05a97bcac7c080a22a0ac4f0c",
                "md5": "971c1d29b1c417156d7d2eea830e463e",
                "sha256": "b07aaa2410caac3a0021ee4f4026acdac992b0fb9a2cbeb34a918617df3c12a7"
            },
            "downloads": -1,
            "filename": "queuelib-1.7.0-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "971c1d29b1c417156d7d2eea830e463e",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": ">=3.8",
            "size": 13562,
            "upload_time": "2024-05-04T06:02:57",
            "upload_time_iso_8601": "2024-05-04T06:02:57.136908Z",
            "url": "https://files.pythonhosted.org/packages/33/c8/63acda77e8b3babed827d868eb04efecb3b05a97bcac7c080a22a0ac4f0c/queuelib-1.7.0-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "fba48af5d8ee3526c64a152549a1c7b42896be9fae9a2fda7712883dc09822ac",
                "md5": "14c25b6f39478e5483a2f0ae42fcfeb1",
                "sha256": "2855162096cf0230510890b354379ea1c0ff19d105d3147d349d2433bb222b08"
            },
            "downloads": -1,
            "filename": "queuelib-1.7.0.tar.gz",
            "has_sig": false,
            "md5_digest": "14c25b6f39478e5483a2f0ae42fcfeb1",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 13291,
            "upload_time": "2024-05-04T06:02:58",
            "upload_time_iso_8601": "2024-05-04T06:02:58.774890Z",
            "url": "https://files.pythonhosted.org/packages/fb/a4/8af5d8ee3526c64a152549a1c7b42896be9fae9a2fda7712883dc09822ac/queuelib-1.7.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-05-04 06:02:58",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "scrapy",
    "github_project": "queuelib",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": true,
    "tox": true,
    "lcname": "queuelib"
}
        
Elapsed time: 0.25637s