From cc00510f5d7d09772f38e1469c391fef1bb0195f Mon Sep 17 00:00:00 2001 From: j Date: Mon, 28 Nov 2016 14:46:52 +0100 Subject: [PATCH] rate limit user cronjob --- pandora/user/tasks.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pandora/user/tasks.py b/pandora/user/tasks.py index 92b60363..e4f06d28 100644 --- a/pandora/user/tasks.py +++ b/pandora/user/tasks.py @@ -8,15 +8,18 @@ from datetime import timedelta from six.moves import zip_longest from celery.task import task, periodic_task +from app.utils import limit_rate from app.models import Settings from .statistics import Statistics @periodic_task(run_every=timedelta(hours=1), queue='encoding') def cronjob(**kwargs): - update_statistics() + if limit_rate('user.tasks.cronjob', 30 * 60): + update_statistics() def update_statistics(): from . import models + def chunker(iterable, chunksize, filler): return zip_longest(*[iter(iterable)]*chunksize, fillvalue=filler)