From 36d500160867fbf0a79c4328c3341dcf6ca4e754 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Thu, 27 Oct 2011 13:38:05 +0200 Subject: [PATCH] cleanup sessions once a day --- pandora/app/tasks.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 pandora/app/tasks.py diff --git a/pandora/app/tasks.py b/pandora/app/tasks.py new file mode 100644 index 000000000..3ac03816c --- /dev/null +++ b/pandora/app/tasks.py @@ -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()