Django application provides simple task model, admin, server services and client service.
Project description
django-simpletask
Django application provides simple task model, admin, server services and client service.
Install
pip install django-simpletask
Usage
pro/settings
INSTALLED_APPS = [
'django_db_lock',
'django_simpletask',
]
DJANGO_SIMPLETASK_ACLKEY = "TsE9Jd3TrUtTA9wjGCLXoDqh891srpyo"
Note:
- Mostly you need a lock service, so we add django_db_lock in INSTALLED_APPS.
- Set DJANGO_SIMPLETASK_ACLKEY to your own aclkey. It will be used in task executor.
app/models.py
from django_simpletask.models import SimpleTask
class Task(SimpleTask):
title = models.CharField(max_length=64)
class Meta:
permissions = [] + SimpleTask.Meta.permissions
def do_task_main(self):
return "done!"
Note:
- Write your own task model based on SimpleTask.
- Add task reset permission.
- Implement you own do_task_main.
app/admin.py
from django.contrib import admin
from .models import Task
class TaskAdmin(admin.ModelAdmin):
list_display = ["title", "status"]
readonly_fields = [] + Task.SIMPLE_TASK_FIELDS
Note:
- Mostly we don't want to change anything inside task, so we set task fields readonly.
task_executor.py
from daemon_application.app import DaemonApplication
from django_simpletask.services import SimpleTaskService
class TaskExcutor(DaemonApplication):
def main(self):
service = SimpleTaskService("http://127.0.0.1:8000/example/task/services/", aclkey="TsE9Jd3TrUtTA9wjGCLXoDqh891srpyo")
service.start()
service.join()
app = TaskExcutor().get_controller()
if __name__ == "__main__":
app()
Note:
- Add task_executor.py script.
- Set the server to your own url.
- Set the aclkey match the DJANGO_SIMPLETASK_ACLKEY setting.
Release
v0.2.8 2020/12/28
- Add SimpleTaskServiceProxy and required views.
- Add get_ready_tasks_queryset to SimpleTaskViews.
v0.2.2 2020/12/03
- Long running service don't use database.
- Add aclkey check for simpletask apis.
v0.1.6 2020/11/17
- Add reset action.
- Add SimpleTask.force_finish.
- Add multi-threads serve.
v0.1.3 2020/11/09
- Add idle_sleep_time parameter for SimpleTask.serve_forever.
v0.1.2 2020/11/09
- Add SimpleTask.serve and SimpleTask.serve_forever.
v0.1.1 2020/10/30
- Add SimpleTask.do_tasks.
v0.1.0 2020/10/26
- First release.
- Take from django-fastadmin. django-fastadmin should forcus on admin extensions, but NOT abstract models.
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
django-simpletask-0.2.8.tar.gz
(11.4 kB
view details)
File details
Details for the file django-simpletask-0.2.8.tar.gz
.
File metadata
- Download URL: django-simpletask-0.2.8.tar.gz
- Upload date:
- Size: 11.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.25.1 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 381ea5fb902162ef10aad2a7ad19e6c2d762b2ed85b337748f623118b3e8362d |
|
MD5 | e3e7e1b6d9b76c634d0430c86a121e0f |
|
BLAKE2b-256 | c72d8d35357affa13f6a6e03616c8761d5c7dde724755bb6c2405934bde3018f |