Django Cloud Task Queue

I’m developing and maintaining a Python package to easily integrate your Django Application with Google Cloud Task.

Some features:

Easily push tasks to Cloud Task using a decorator
Automatically route all tasks from a single endpoint
Ease scheduling…


This content originally appeared on DEV Community and was authored by AM

I’m developing and maintaining a Python package to easily integrate your Django Application with Google Cloud Task.

Some features:

  • Easily push tasks to Cloud Task using a decorator
  • Automatically route all tasks from a single endpoint
  • Ease scheduling with native python datetime
  • Named task to avoid duplicated
  • Local development support (coming soon...)

Simple and beautiful task definition

from datetime import timedelta
from django.utils.timezone import now
from cloudtask import (
    CloudTaskRequest,
    task)

@task(queue='default')
def add(request: CloudTaskRequest, a: int = 5, b: int = 4) -> None:
    print(f'Running task with args {a=} and {b=}')
    print(a + b)

# pushing task to queue
add(a=2, b=4).delay()

# executing the task immediately without push to queue
add(a=30)()

# scheduling the task
at = now() + timedelta(days=1)
add(b=15).schedule(at=at)

See the repository and full documentation on my Github page.

If it was helpful or if you found it interesting, also leave an 🙋🏽‍♂️❤️ in the comments. Thank you, looking forward to the next article. Enjoy and follow my work.

Thanks,
Stay safe!


This content originally appeared on DEV Community and was authored by AM


Print Share Comment Cite Upload Translate Updates
APA

AM | Sciencx (2021-10-08T21:15:01+00:00) Django Cloud Task Queue. Retrieved from https://www.scien.cx/2021/10/08/django-cloud-task-queue/

MLA
" » Django Cloud Task Queue." AM | Sciencx - Friday October 8, 2021, https://www.scien.cx/2021/10/08/django-cloud-task-queue/
HARVARD
AM | Sciencx Friday October 8, 2021 » Django Cloud Task Queue., viewed ,<https://www.scien.cx/2021/10/08/django-cloud-task-queue/>
VANCOUVER
AM | Sciencx - » Django Cloud Task Queue. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/10/08/django-cloud-task-queue/
CHICAGO
" » Django Cloud Task Queue." AM | Sciencx - Accessed . https://www.scien.cx/2021/10/08/django-cloud-task-queue/
IEEE
" » Django Cloud Task Queue." AM | Sciencx [Online]. Available: https://www.scien.cx/2021/10/08/django-cloud-task-queue/. [Accessed: ]
rf:citation
» Django Cloud Task Queue | AM | Sciencx | https://www.scien.cx/2021/10/08/django-cloud-task-queue/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.