ModelQueue is an Apache2 licensed task queue based on Django models.
For example, in appname/models.py:
import modelqueue
from django.db import models
class Task(models.Model):
data = models.TextField()
status = modelqueue.StatusField(
# ^-- Just a models.BigIntegerField
db_index=True,
# ^-- Index for faster queries.
default=modelqueue.Status.waiting,
# ^-- Waiting state is ready to run.
)
And in appname/management/commands/process_tasks.py:
import modelqueue, time
from django.core.management.base import BaseCommand
from .models import Task
class Command(BaseCommand):
def handle(self, *args, **options):
while True:
task = modelqueue.run(
Task.objects.all(),
# ^-- Queryset of models to process.
'status',
# ^-- Field name for model queue.
self.process,
# ^-- Callable to process model.
)
if task is None:
time.sleep(1)
# ^-- Bring your own parallelism/concurrency.
def process(self, task):
pass # Process task models.
And in appname/admin.py:
class TaskAdmin(admin.ModelAdmin):
actions = [*modelqueue.admin_actions('status')]
# ^-- Change task status in admin.
list_filter = [
modelqueue.admin_list_filter('status'),
# ^-- Filter tasks in admin by queue state.
]
def get_changeform_initial_data(self, request):
# v-- Automatically fill in status field when adding a new task.
return {'status': int(modelqueue.Status.waiting())}
ModelQueue is a hazardous project. It takes a bad idea and makes it easy and effective. You may come to regret using your database as a task queue but it won’t be today!
Testimonials
“I didn’t design relational database systems for this.” ~ Edgar Codd
“Well, at least you’re using transactions.” ~ Jim Gray
“You have successfully ignored most of what’s important in queueing theory.” ~ Agner Erlang
Does your company or website use ModelQueue? Send us a message and let us know.
Features
Pure-Python
Supports Django’s admin interface
Tasks can be retried, aborted, and canceled
Supports multiple attempts per task
Bring your own parallelism with threading, multiprocessing, or asyncio
Performance matters (add a single 64-bit field to models)
Fully documented
100% test coverage
Years of stress testing in production
Developed on Python 3.10
Compatible with all Django versions
Tested on CPython 3.6, 3.7, 3.8, 3.9, 3.10
Tested on Linux, Mac OS X, and Windows
Quickstart
Installing ModelQueue is simple with pip:
$ python -m pip install modelqueue
You can access documentation in the interpreter with Python’s built-in help function:
>>> import modelqueue >>> help(modelqueue)
User Guide
For those wanting more details, this part of the documentation describes introduction, benchmarks, development, and API.
Reference and Indices
ModelQueue License
Copyright 2022 Grant Jenks
Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Metadata
Release files for modelqueue 2.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| modelqueue-2.2.1.tar.gz | 8.5 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| modelqueue-2.2.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 17.3 kB
Release files / modelqueue-2.2.1.tar.gz
| Download URL | modelqueue-2.2.1.tar.gz |
|---|---|
| Size | 8.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
11d325719933803dc0d79bce00cd4e2ab17224a0d6932a21bc46ae03fad275fd
|
|
BLAKE2b-256 checksum How to use checksums |
b56b1e6b48b717846e317685058144cd250adfda360ca61e93ac75d0549bb241
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.0 CPython/3.10.2
|
Release files / modelqueue-2.2.1-py3-none-any.whl
| Download URL | modelqueue-2.2.1-py3-none-any.whl |
|---|---|
| Size | 8.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
31a270939d997a1bf2587c4adfd8ad850438d5f0839b7c2d87f95a43d3d40ad3
|
|
BLAKE2b-256 checksum How to use checksums |
0c7c156b3c909c136cd05b6732949a87d1f3dc3e2de7f623aa814c4c2086939f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.0 CPython/3.10.2
|
Security for modelqueue 2.2.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.