I'm executing some of the long-running tasks with Django-background-tasks. Background task takes some data from DB and process it internally which requires memory of 1 GB for each task.
The task is running in the async way.
When any task runs and completes its execution, Django-background-tasks does not release the memory after completing execution. Which causing memory issues to the Dameon pod. Any solution around deallocation of memory resources in Django-background-task? E.g.
Note: resources available are fixed. so need a workaround on resource deallocation of tasks. Currently, memory gets deallocated when the pod restarts.
This is how module structure looks like.
../bulk_file_operations/
├── apps.py
├── tasks.py
├── views.py
├── file_handler.py
tasks.py
@background()
def my_task():
"""
a long-running task that takes time of 20-30 mins, which includes some DB interactions.
"""
process_data_n_download(model_queryset_object)
pass
file_handler.py
def process_data_n_download(queryset_object):
"""process this ORM object for file creation."""
pass