What should I use Django Non-Global Middlewares or Django triggers

73 Views Asked by At

My problem is basically that I am currently making a customized management system based on Django(3.1) Python(v3.7.9) in which I am pulling the data from a third-party tool. The tool is not giving me the webhooks of every data that I want for visualization and analysis.

The webhook is giving me bits of information and I have to perform a GET request to their API to fetch the rest details if those are not in my database. They are asking for a successful response of webhook within 5 secs otherwise it will trigger a retry.

If I try to do a get request within the function of webhook the time of 5 second will get exceeded the solutions that I came up with was to Django Middleware or Django Triggers so which would be best suitable for my problem I am bit confused.

Note: I can not lower the Django version as I have to use Async Functions

1

There are 1 best solutions below

0
On BEST ANSWER

This would be a good use case for a task scheduler like Celery. Django-triggers is an interface to the Celery scheduler, so it might be a good fit. Keep in mind, Celery has to be run as a separate process next to django.

Another popular task scheduler is rq-scheduler. This offers a simple implementation using Redis as a message queue. *Note that Loadbalanced/multi-instance applications are not easily setup with RQ.