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.db import models
from django_simpletask.models import SimpleTask
class Task1(SimpleTask):
title = models.CharField(max_length=64)
class Meta:
permissions = [] + SimpleTask.Meta.permissions
def do_task_main(self):
return "done!"
class Task2(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 django_simpletask.admin import SimpleTaskAdmin
from .models import Task1
from .models import Task2
class TaskAdmin(SimpleTaskAdmin, admin.ModelAdmin):
list_display = ["title"] + SimpleTaskAdmin.list_display
admin.site.register(Task1, TaskAdmin)
admin.site.register(Task2, TaskAdmin)
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.1.0
- First release.
- Take from django-fastadmin. django-fastadmin should forcus on admin extensions, but NOT abstract models.
v0.1.1
- Add SimpleTask.do_tasks.
v0.1.2
- Add SimpleTask.serve and SimpleTask.serve_forever.
v0.1.3
- Add idle_sleep_time parameter for SimpleTask.serve_forever.
v0.1.6
- Add reset action.
- Add SimpleTask.force_finish.
- Add multi-threads serve.
v0.2.2
- Long running service don't use database.
- Add aclkey check for simpletask apis.
v0.2.8
- Add SimpleTaskServiceProxy and required views.
- Add get_ready_tasks_queryset to SimpleTaskViews.
v0.2.9
- Add channel params.
v0.3.5
- Bad response handler.
- Services changed a a lot.
v0.3.6
- Doc update.
v0.3.7
- Fix ugettext problem.
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.3.7.tar.gz
(14.3 kB
view details)
Built Distribution
File details
Details for the file django-simpletask-0.3.7.tar.gz
.
File metadata
- Download URL: django-simpletask-0.3.7.tar.gz
- Upload date:
- Size: 14.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ce816d92547bca9f9efb25accdfe1abd8e07c3ab0160c661d19558764af71859 |
|
MD5 | d70093c9fec255f7ac00f050c8ed90c9 |
|
BLAKE2b-256 | afdbef4e3ee767bf2fea125376dcee1f4579b234096a93a7c7935947d7968d84 |
File details
Details for the file django_simpletask-0.3.7-py3-none-any.whl
.
File metadata
- Download URL: django_simpletask-0.3.7-py3-none-any.whl
- Upload date:
- Size: 16.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3c15a2251ffe9d392075ee6ff4994421c2fbdce323dcd0ac81818d11eaa897fe |
|
MD5 | 183817710381e0615ffff16505c10763 |
|
BLAKE2b-256 | d654bafaa25dd71fd095dd77c6a10e4e7a17b71aac80d458f3456ae62c9bc471 |