Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
.. 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)
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
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.
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'
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'
Use the scrapy-users
_ mailing list for questions about Queuelib.
If you have any suggestions, bug reports or annoyances please report them to our issue tracker at: http://github.com/scrapy/queuelib/issues/
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 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
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
_
.. _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/
FAQs
Collection of persistent (disk-based) and non-persistent (memory-based) queues
We found that queuelib demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.