2020-09-27 08:02:44 +00:00
|
|
|
from celery import shared_task
|
2020-12-10 09:12:39 +00:00
|
|
|
from django.utils.translation import gettext_lazy as _
|
2020-09-27 08:02:44 +00:00
|
|
|
|
2020-11-20 08:12:24 +00:00
|
|
|
from ops.celery.decorator import register_as_period_task
|
2020-09-27 08:02:44 +00:00
|
|
|
from assets.utils import check_node_assets_amount
|
2020-12-10 09:12:39 +00:00
|
|
|
|
|
|
|
from common.utils.lock import AcquireFailed
|
2020-09-27 08:02:44 +00:00
|
|
|
from common.utils import get_logger
|
|
|
|
|
|
|
|
logger = get_logger(__file__)
|
|
|
|
|
|
|
|
|
2020-11-20 12:23:09 +00:00
|
|
|
@shared_task(queue='celery_heavy_tasks')
|
2020-12-10 09:12:39 +00:00
|
|
|
@register_as_period_task(crontab='0 2 * * *')
|
|
|
|
def check_node_assets_amount_period_task():
|
|
|
|
try:
|
|
|
|
check_node_assets_amount()
|
|
|
|
except AcquireFailed:
|
|
|
|
logger.error(_('The task of self-checking is already running and cannot be started repeatedly'))
|