All Projects → ericls → django-simple-task

ericls / django-simple-task

Licence: MIT license
Simple background task for Django 3

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to django-simple-task

async-asgi-testclient
A framework-agnostic library for testing ASGI web applications
Stars: ✭ 123 (+39.77%)
Mutual labels:  asgi
gow
Missing watch mode for Go commands. Watch Go files and execute a command like "go run" or "go test"
Stars: ✭ 343 (+289.77%)
Mutual labels:  task-runner
gilbert
Build system and task runner for Go projects
Stars: ✭ 105 (+19.32%)
Mutual labels:  task-runner
taskctl
Concurrent task runner, developer's routine tasks automation toolkit. Simple modern alternative to GNU Make 🧰
Stars: ✭ 237 (+169.32%)
Mutual labels:  task-runner
ngx upstream jdomain
An asynchronous domain name resolution module for nginx upstream.
Stars: ✭ 71 (-19.32%)
Mutual labels:  task-runner
bask
A runner and framework for command-centric Bash scripts.
Stars: ✭ 31 (-64.77%)
Mutual labels:  task-runner
asgi-caches
Server-side HTTP caching for ASGI applications, inspired by Django's cache framework
Stars: ✭ 18 (-79.55%)
Mutual labels:  asgi
elk
🦌 Minimalist yaml based task runner
Stars: ✭ 43 (-51.14%)
Mutual labels:  task-runner
myrmidon
A rofi task / command executor
Stars: ✭ 82 (-6.82%)
Mutual labels:  task-runner
alfons
🚀 Task runner for Lua and MoonScript.
Stars: ✭ 17 (-80.68%)
Mutual labels:  task-runner
Spontini
A text-combined-with-graphic music editor for creating professional scores with LilyPond
Stars: ✭ 43 (-51.14%)
Mutual labels:  asgi
starlite
Light, Flexible and Extensible ASGI API framework
Stars: ✭ 1,525 (+1632.95%)
Mutual labels:  asgi
asgi-csrf
ASGI middleware for protecting against CSRF attacks
Stars: ✭ 43 (-51.14%)
Mutual labels:  asgi
dashboard
An admin interface for ASGI Web frameworks.
Stars: ✭ 120 (+36.36%)
Mutual labels:  asgi
a2wsgi
Convert WSGI app to ASGI app or ASGI app to WSGI app.
Stars: ✭ 78 (-11.36%)
Mutual labels:  asgi
fastapi-project
FastAPI application without global variables(almost) =)
Stars: ✭ 26 (-70.45%)
Mutual labels:  asgi
runfile
Command line for your projects
Stars: ✭ 22 (-75%)
Mutual labels:  task-runner
livelog
A Django Channels example project to demonstrate the ASGI use case.
Stars: ✭ 20 (-77.27%)
Mutual labels:  asgi
duty
A simple task runner.
Stars: ✭ 36 (-59.09%)
Mutual labels:  task-runner
TikTokDownloader PyWebIO
🚀「Douyin_TikTok_Download_API」是一个开箱即用的高性能异步抖音|TikTok数据爬取工具,支持API调用,在线批量解析及下载。
Stars: ✭ 919 (+944.32%)
Mutual labels:  asgi

Django Simple Task

Github Actions Documentation Status Code Coverage Python Version PyPI Package License

django-simple-task runs background tasks in Django 3 without requiring other services and workers. It runs them in the same event loop as your ASGI application. It is not resilient as a proper task runner such as Celery, but works for some simple tasks and has less overall overheads.

Requirements

django-simple-task expect ASGI lifespan protocol to be supported by the server. Currently Daphne does not support this.

This package is tested with:

  • Python 3.7, 3.8 and 3.9,
  • Django 3.1 and 3.2.

Guide

Install the package:

pip install django-simple-task

Added it to installed apps:

# settings.py
INSTALLED_APPS = [
	...
	'django_simple_task'
]

Apply ASGI middleware :

# asgi.py
from django_simple_task import django_simple_task_middlware
application = django_simple_task_middlware(application)

Call a background task in Django view:

from django_simple_task import defer

def task1():
	time.sleep(1)
	print("task1 done")

async def task2():
	await asyncio.sleep(1)
	print("task2 done")

def view(requests):
	defer(task1)
	defer(task2)
	return HttpResponse(b"My View")

It is required to run Django with ASGI server. Official Doc

Configurations

Concurrency level can be controlled by adding DJANGO_SIMPLE_TASK_WORKERS to settings. Defaults to 1.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].