cleanup sessions once a day
This commit is contained in:
parent
fc1047bde1
commit
36d5001608
1 changed files with 14 additions and 0 deletions
14
pandora/app/tasks.py
Normal file
14
pandora/app/tasks.py
Normal file
|
@ -0,0 +1,14 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# vi:si:et:sw=4:sts=4:ts=4
|
||||
import datetime
|
||||
|
||||
from celery.decorators import task, periodic_task
|
||||
from celery.task.schedules import crontab
|
||||
|
||||
|
||||
@periodic_task(run_every=crontab(hour=6, minute=0), queue='encoding')
|
||||
def cron(**kwargs):
|
||||
from django.db import transaction
|
||||
from django.contrib.sessions.models import Session
|
||||
Session.objects.filter(expire_date__lt=datetime.datetime.now()).delete()
|
||||
transaction.commit_unless_managed()
|
Loading…
Reference in a new issue