Skip to main content

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.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


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.2.tar.gz (10.6 kB view details)

Uploaded Source

File details

Details for the file django-simpletask-0.2.2.tar.gz.

File metadata

  • Download URL: django-simpletask-0.2.2.tar.gz
  • Upload date:
  • Size: 10.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/39.2.0 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.6.8

File hashes

Hashes for django-simpletask-0.2.2.tar.gz
Algorithm Hash digest
SHA256 9e15ef76a90cacbf4f8bd0689b0e02e6c5f363b1fc398f23f13668d0f5da0620
MD5 f7d9ae8ec6af2990b424cae481b96b88
BLAKE2b-256 bbf58c2be6ff658ec4fa0b242686083bb6faad3d46e849f3e75b65c3cc3b34a2

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page