2019-02-26 13:07:47 +00:00
|
|
|
"""passbook core tasks"""
|
2019-04-04 19:49:10 +00:00
|
|
|
from datetime import datetime
|
|
|
|
|
2019-10-01 08:24:10 +00:00
|
|
|
from structlog import get_logger
|
2019-02-26 13:07:47 +00:00
|
|
|
|
2019-04-04 19:49:10 +00:00
|
|
|
from passbook.core.models import Nonce
|
2019-06-25 16:00:54 +00:00
|
|
|
from passbook.root.celery import CELERY_APP
|
2019-02-26 13:07:47 +00:00
|
|
|
|
2019-10-04 08:08:53 +00:00
|
|
|
LOGGER = get_logger()
|
2019-02-26 13:07:47 +00:00
|
|
|
|
2019-04-04 19:49:10 +00:00
|
|
|
@CELERY_APP.task()
|
|
|
|
def clean_nonces():
|
|
|
|
"""Remove expired nonces"""
|
2019-04-11 08:43:13 +00:00
|
|
|
amount, _ = Nonce.objects.filter(expires__lt=datetime.now(), expiring=True).delete()
|
2019-10-08 12:30:17 +00:00
|
|
|
LOGGER.debug("Deleted expired nonces", amount=amount)
|