jumpserver/apps/authentication/tasks.py

15 lines
453 B
Python
Raw Normal View History

2019-02-27 00:45:00 +00:00
# -*- coding: utf-8 -*-
#
from celery import shared_task
from ops.celery.decorator import register_as_period_task
from django.contrib.sessions.models import Session
from django.utils import timezone
2023-02-02 07:57:06 +00:00
from django.utils.translation import gettext_lazy as _
2019-02-27 00:45:00 +00:00
2023-02-02 07:57:06 +00:00
@shared_task(verbose_name=_('Clean expired session'))
@register_as_period_task(interval=3600 * 24)
def clean_django_sessions():
Session.objects.filter(expire_date__lt=timezone.now()).delete()