pandora/pandora/app/utils.py
2020-05-30 21:23:16 +02:00

14 lines
326 B
Python

# -*- coding: utf-8 -*-
import time
from .models import Settings
def limit_rate(key, timeout):
key = 'limit.%s.last' % key
last_cronjob = Settings.get(key, 0)
current_time = time.time()
if (current_time - last_cronjob) > timeout:
Settings.set(key, current_time)
return True
return False