
Security News
Software Engineering Daily Podcast: Feross on AI, Open Source, and Supply Chain Risk
Socket CEO Feross Aboukhadijeh joins Software Engineering Daily to discuss modern software supply chain attacks and rising AI-driven security risks.
litequeue
Advanced tools
Queue implemented on top of SQLite
You can use this to implement a persistent queue. It also has extra timing
metrics for the messages/tasks, and the api to set a message as done lets
you specifiy the message_id to be set as done.
Since it's all based on SQLite / SQL, it is easily extendable.
Messages are always passed as strings, so you can use json data as messages.
Messages are interpreted as tasks, so after you pop a message, you need to
mark it as done when you finish processing it. When you run the .prune()
method, it will remove all the finished tasks from the database.
Create a virtual environment if you are alredy not inside one and install the package using pip:
python3 -m venv .venv
python3 -m pip --require-virtualenv install --upgrade litequeue
from litequeue import LiteQueue
q = LiteQueue(":memory:")
q.put("hello")
q.put("world")
# Message object used by LiteQueue
# Message(data='world', message_id=UUID('063e95f1-3d9f-7547-8000-c3eb531fff93'), status=<MessageStatus.READY: 0>, in_time=1676238611851409010, lock_time=None, done_time=None)
task = q.pop()
print(task)
# Message(data='hello', message_id='063e95f1-3d9e-7bbc-8000-a6a18a5f65d1', status=1, in_time=1676238611851279408, lock_time=1676238623180543854, done_time=None)
q.done(task.message_id)
q.get(task.message_id)
# Message(
# data='hello',
# message_id='063e95f1-3d9e-7bbc-8000-a6a18a5f65d1',
# status=2, <---- status is now 2 (DONE)
# in_time=1676238611851279408,
# lock_time=1676238623180543854,
# done_time=1676238641276753673
# )
Check out the docs page for more.
queue.Queuemessage_id to set as done)You can have a look at the test.py file. The tests are short and showcase
different usage scenarios.
The benchmark.ipynb file contains some benchmarks comparing litequeue to
the built-in Python queue.Queue.
In the LiteQueue class, the filename_or_conn parameter defines the SQLite
file that will be used to store the messages, the queue_name parameter is used
to define the table name that will be used to store the messages.
Multiple queues in the same SQLite is supported, but it's neither tested nor
recommended. But if you need it, you can use different queue_name values when
initializing the LiteQueue object to store multiple queues in the same DB
file.
import tempfile
import litequeue
with tempfile.TemporaryDirectory() as tmpdirname:
db_path = tmpdirname + "/test.sqlite3"
q1 = litequeue.LiteQueue(db_path, queue_name="q1")
q2 = litequeue.LiteQueue(db_path, queue_name="q2")
q1.put("a")
q1.put("b")
print("Q1 size", q1.qsize())
print("Q2 size", q2.qsize())
q2.put("c")
q2.put("d")
print("Q2 size", q2.qsize())
print(q1.pop())
print(q1.peek())
print(q2.peek())
print(q2.pop())
Ricardo Ander-Egg Aguilar – @ricardoanderegg –
Distributed under the MIT license. See LICENSE for more information.
message is now data.task_id is now message_id.The only hard rules for the project are:
litequeue.py file.test.py file.black and isort, using one import per line.FAQs
Simple queue built on top of SQLite
We found that litequeue demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer 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
Socket CEO Feross Aboukhadijeh joins Software Engineering Daily to discuss modern software supply chain attacks and rising AI-driven security risks.

Security News
GitHub has revoked npm classic tokens for publishing; maintainers must migrate, but OpenJS warns OIDC trusted publishing still has risky gaps for critical projects.

Security News
Rust’s crates.io team is advancing an RFC to add a Security tab that surfaces RustSec vulnerability and unsoundness advisories directly on crate pages.