inventory / backend / main / tasks.py
tasks.py
Raw
from celery import shared_task
import requests
import json
from main.models import *
from django.core import management


@shared_task
def cleanup():
    try:

        """Cleanup expired sessions by using Django management command."""
        management.call_command("clearsessions", verbosity=0)
        management.call_command("clean_duplicate_history", "--auto")
        management.call_command("clean_old_history", "--auto")
        return "success"
    except Exception as e:
        print(e)