Task queue based on Django models.
Project description
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( 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(0.1) # ^-- Bring your own parallelism/concurrency. def process(self, report): pass # Process task models.
And in appname/admin.py:
class TaskAdmin(admin.TaskAdmin): list_filter = [ modelqueue.admin_list_filter('status'), # ^-- Filter tasks in admin by queue state. ]
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
Fully documented
Performance matters
100% test coverage
Hours of stress testing
Developed on Python 3.6
Tested on Django 1.11
Tested on CPython 2.7, 3.4, 3.5, 3.6, PyPy and PyPy3
Tested on Linux, Mac OS X, and Windows
Tested using Travis CI and AppVeyor CI
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 2018 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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file modelqueue-1.0.2.tar.gz
.
File metadata
- Download URL: modelqueue-1.0.2.tar.gz
- Upload date:
- Size: 7.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7b16a126cb883de09ec9622282eec2b8b296df25169eaf33f9650637b793a872 |
|
MD5 | 0ffcd7a87bac7f11f427b3ad2fcece97 |
|
BLAKE2b-256 | e94158984d1d202331ee427986d8b18d51c77c41012c9011e70f7ec1ee1d4395 |
File details
Details for the file modelqueue-1.0.2-py2.py3-none-any.whl
.
File metadata
- Download URL: modelqueue-1.0.2-py2.py3-none-any.whl
- Upload date:
- Size: 9.7 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 09ffe0fd86cf6e66f91b6456e99653aa7c69b109f1f73ddf5ce45471eeae10d3 |
|
MD5 | e27abb3a6132566eb58b8b86b7a527b3 |
|
BLAKE2b-256 | 640b426a8797790653709ef84e6c379b9c068f11263a95d466d9d56e9f58d166 |