Skip to main content

Chard

Chard is a simple async/await background task queue for Django. One process, no threads, no other dependencies.

It uses Django's ORM to keep track of tasks. This is a new project under active development. PRs are welcome!

📖 Documentation

📨 Sign up to the newsletter to get news and updates

🔗 Check the example Django project

Requirements

  • Python 3.8+
  • Django 4.1+

Installation

pip install django-chard

Quickstart

First add chard anywhere in your INSTALLED_APPS setting and then run the migrations:

python manage.py migrate

Create a file called tasks.py in one of your apps and define a task:

import chard
import httpx
from asgiref.sync import sync_to_async

from .models import MyModel

@chard.task
async def my_task(country_code):
    url = f"https://somewhere.com/some-api.json?country_code={country_code}"
    async with httpx.AsyncClient() as client:
        resp = await client.get(url)
        obj = resp.json()
    for item in obj["items"]:
        await sync_to_async(MyModel.objects.create)(
          country_code=country_code,
          item=item
        )

To fire a task for the worker:

# Note that all arguments must be JSON serializable.
my_task.send("gb")

Run the worker process and it will watch for new pending tasks:

python manage.py chardworker

To see a full example of Chard in action:

🔗 Check the example Django project

Contributing

Please see CONTRIBUTING the contributing guidelines.

License

Please see LICENSE for licensing details.

Changelog

0.2 (2022-09-16)

- Type hinting
- Return a task ID when queueing a task
- Added docs
- Tidying and bug fixes

Metadata

Release files for django-chard 0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-chard 0.2
File Size Uploaded Provenance Actions
django-chard-0.2.tar.gz 7.1 kB Without provenance Details for django-chard-0.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for django-chard 0.2
File Interpreter ABI Platform Actions
django_chard-0.2-py3-none-any.whl Python 3 none any Details for django_chard-0.2-py3-none-any.whl

Total release size: 15.3 kB

Release files / django-chard-0.2.tar.gz

Download URL django-chard-0.2.tar.gz
Size 7.1 kB
Tags Source
SHA-256 checksum
How to use checksums
d979969941c584fe402310746d3f540cba90c844b9be91c50a450f984fd180dc
BLAKE2b-256 checksum
How to use checksums
80ba32b1d97804fbee7ede7b3bd16db7dd41009e197a49ead9f2003acf6c21a2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.5

Release files / django_chard-0.2-py3-none-any.whl

Download URL django_chard-0.2-py3-none-any.whl
Size 8.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3c9f2726feb9af26eaa839d2f2990719612a26bb8f8a5406b74c077523e92a87
BLAKE2b-256 checksum
How to use checksums
5e57c8767d677c11d99a4c52d025ef898cc232869b937a7ee893b9fdc4650fe1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.5

Security for django-chard 0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page