Manage long running tasks out of request-response cycle with Django's all-new `Task` back-end and AWS/Azure native-services.
Project description
Django Task Backend for AWS and Azure
❌ IMPORTANT This project is in its early stages. While it is functional, it may not cover all edge cases or have comprehensive documentation. Use it at your own risk and feel free to contribute! We are working fast to make it production-ready.
This project aims to use Django's new Task back-end to expose AWS and Azure native services to manage long-running tasks asynchronously. This project is useful for tasks that must run outside the request-response cycle, like sending emails, processing images, or running machine learning models. It leverages the power of AWS and Azure native services. You can choose between the two cloud providers (more on this in the installation and setup sections). With the reliance on cloud native services, the project provides a scalable and reliable solution for managing long-running tasks.
Installation
Installation depends on which cloud provider you want to use. You can install the package using PIP for all cloud providers as follows:
pip install django-cloud-task
For AWS:
pip install django-cloud-task[aws]
For Azure:
pip install django-cloud-task[azure]
Once installed, add it to your Django INSTALLED_APPS in settings.py:
INSTALLED_APPS = [
...
"django_cloud_task",
# Either or Both
"django_cloud_task_aws", # For AWS
"django_cloud_task_azure", # For Azure
...
]
Configuration
AWS: SQS
To configure AWS SQS as your task backend, add the following settings to your settings.py:
AWS: SNS
AWS: EventBridge
Azure: Service Bus Queue
TASKS = {
"default": {
"BACKEND": "django_cloud_tasks_azure.backends.service_bus.ServiceBusQueueBackend",
"QUEUES": ["default"],
"OPTIONS": {
"SERVICEBUS_DEFAULT_QUEUE_NAME": "testing",
"SERVICEBUS_USE_CONNECTION_STRING": True,
"SERVICEBUS_CONNECTION_STRING": "",
"SERVICEBUS_NAMESPACE_FQDN": "",
"SERVICEBUS_CREDENTIAL_LOADER": "this.that.custom_credential_loader_function",
},
},
}
For a simple setup, you can use the SERVICEBUS_USE_CONNECTION_STRING option set to True and provide the SERVICEBUS_CONNECTION_STRING. This connection string can be obtained from the Azure portal.
If you don't wanna hardcode credentials, you must provide the SERVICEBUS_NAMESPACE_FQDN and provide SERVICEBUS_CREDENTIAL_LOADER. If you don't provide a custom credential loader, the default will use DefaultAzureCredential from the azure-identity package.
To use a custom credential class from a suite of Azure credential classes, set the SERVICEBUS_CREDENTIAL_LOADER option to a method of the following function signature:
def custom_credential_loader() -> TokenCredential: ...
Mention it's full module path in the SERVICEBUS_CREDENTIAL_LOADER setting. The function must return an instance of a class that inherits from azure.core.credentials.TokenCredential. A function wrapper is required because some TokenCredential classes require parameters for initialization. To know more about the available credential classes, refer to the Azure Identity documentation.
[!IMPORTANT]
QUEUESis a list of queue names that you want to use. Each queue name in the list corresponds to a queue that you have created in your Azure Service Bus namespace.
Azure: Service Bus Topic
TASKS = {
"default": {
"BACKEND": "django_cloud_tasks_azure.backends.service_bus.ServiceBusTopicBackend",
"QUEUES": ["default"],
"OPTIONS": {
"SERVICEBUS_DEFAULT_TOPIC_NAME": "testing",
"SERVICEBUS_USE_CONNECTION_STRING": True,
"SERVICEBUS_CONNECTION_STRING": "",
"SERVICEBUS_NAMESPACE_FQDN": "",
"SERVICEBUS_CREDENTIAL_LOADER": "this.that.custom_credential_loader_function",
},
},
}
The configuration is similar to the Service Bus Queue backend. The main difference is that you need to provide the SERVICEBUS_DEFAULT_TOPIC_NAME instead of the queue name.
Azure: Storage Account Queue
TASKS = {
"default": {
"BACKEND": "django_cloud_tasks_azure.backends.storage_queue.StorageAccountQueueBackend",
"QUEUES": ["default"],
"OPTIONS": {
"STORAGE_ACCOUNT_QUEUE_DEFAULT_QUEUE_NAME": "testing",
"STORAGE_ACCOUNT_USE_CONNECTION_STRING": True,
"STORAGE_ACCOUNT_CONNECTION_STRING": "",
"STORAGE_ACCOUNT_NAME": "",
"STORAGE_ACCOUNT_CREDENTIAL_LOADER": "this.that.custom_credential_loader_function",
},
},
}
The configuration is similar to the Service Bus Queue backend. The main difference is that you need to provide the STORAGE_ACCOUNT_QUEUE_DEFAULT_QUEUE_NAME instead of the queue name.
Contributing
Contributions are welcome! Please read the CONTRIBUTING.md file for more information on how to contribute to this project.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file django_tasks_cloud-0.1.0b2.tar.gz.
File metadata
- Download URL: django_tasks_cloud-0.1.0b2.tar.gz
- Upload date:
- Size: 7.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2743e44796976042439f758c88fc2a81a49e0010b82f7881d50aaaa2379c49af
|
|
| MD5 |
d6ac9b2dbcbd83d59ffb9056e185a463
|
|
| BLAKE2b-256 |
0bfadd00c389e3d9640008145a3bd8d0294abcbc3eef01ff3dd7baefca3bc982
|
Provenance
The following attestation bundles were made for django_tasks_cloud-0.1.0b2.tar.gz:
Publisher:
cd.yml on papercloudtech/django-tasks-cloud
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
django_tasks_cloud-0.1.0b2.tar.gz -
Subject digest:
2743e44796976042439f758c88fc2a81a49e0010b82f7881d50aaaa2379c49af - Sigstore transparency entry: 765398562
- Sigstore integration time:
-
Permalink:
papercloudtech/django-tasks-cloud@06b61ccb4df6442080e418b22ad47fb199186e3f -
Branch / Tag:
refs/tags/v0.1.0b2 - Owner: https://github.com/papercloudtech
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
cd.yml@06b61ccb4df6442080e418b22ad47fb199186e3f -
Trigger Event:
push
-
Statement type:
File details
Details for the file django_tasks_cloud-0.1.0b2-py3-none-any.whl.
File metadata
- Download URL: django_tasks_cloud-0.1.0b2-py3-none-any.whl
- Upload date:
- Size: 15.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
750f4a29d83544549c8aab29802618ce26c9bf5e157cf3a7b9421d3645089b53
|
|
| MD5 |
5b6cb24e85486d287589ab05fae9ef38
|
|
| BLAKE2b-256 |
05f8351fc070a19fc7f926f427bc8deb76c533c991fa86c00550f2a492c89464
|
Provenance
The following attestation bundles were made for django_tasks_cloud-0.1.0b2-py3-none-any.whl:
Publisher:
cd.yml on papercloudtech/django-tasks-cloud
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
django_tasks_cloud-0.1.0b2-py3-none-any.whl -
Subject digest:
750f4a29d83544549c8aab29802618ce26c9bf5e157cf3a7b9421d3645089b53 - Sigstore transparency entry: 765398564
- Sigstore integration time:
-
Permalink:
papercloudtech/django-tasks-cloud@06b61ccb4df6442080e418b22ad47fb199186e3f -
Branch / Tag:
refs/tags/v0.1.0b2 - Owner: https://github.com/papercloudtech
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
cd.yml@06b61ccb4df6442080e418b22ad47fb199186e3f -
Trigger Event:
push
-
Statement type: