test/mfssogr/celery.py

61 lines
2.8 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import os
from celery import Celery
#from celery.schedules import crontab
from datetime import timedelta
# set the default Django settings module for the 'celery' program.
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mfssogr.settings')
app = Celery('mfssogr')
# Using a string here means the worker doesn't have to serialize
# the configuration object to child processes.
# - namespace='CELERY' means all celery-related configuration keys
# should have a `CELERY_` prefix.
app.config_from_object('django.conf:settings', namespace='CELERY')
# Load task modules from all registered Django app configs.
app.autodiscover_tasks()
@app.task(bind=True, ignore_result=True)
def debug_task(self):
print(f'Request: {self.request!r}')
app.conf.enable_utc = False
app.conf.beat_schedule = {
'apps.schedulers.tasks.load_earthquake': {# Получение данных по землятресениям
'task': 'apps.schedulers.tasks.load_earthquake',
'schedule': timedelta(minutes=30), # change to `crontab(minute=0, hour=0)` if you want it to run daily at midnight
},
'apps.schedulers.tasks.load_navigation': {# Получение данных по навигации
'task': 'apps.schedulers.tasks.load_navigation',
'schedule': timedelta(seconds=10), # change to `crontab(minute=0, hour=0)` if you want it to run daily at midnight
},
#'apps.schedulers.tasks.update_block': {# Получение данных по блокировкам
# 'task': 'apps.schedulers.tasks.update_block',
# 'schedule': timedelta(seconds=10), # change to `crontab(minute=0, hour=0)` if you want it to run daily at midnight
#},
#'apps.schedulers.tasks.update_ops_skpv_date': { # Получение данных со водоснабжение
# 'task': 'apps.schedulers.tasks.update_ops_skpv_date',
# 'schedule': timedelta(seconds=10), # change to `crontab(minute=0, hour=0)` if you want it to run daily at midnight
#},
#'apps.schedulers.tasks.update_ops_ppz_date': { # Получение данных противопожарная защита
# 'task': 'apps.schedulers.tasks.update_ops_ppz_date',
# 'schedule': timedelta(seconds=10), # change to `crontab(minute=0, hour=0)` if you want it to run daily at midnight
#},
#'apps.schedulers.tasks.update_ops_scada_date': { # Получение данных Системы контроля работы оборудования
# 'task': 'apps.schedulers.tasks.update_ops_scada_date',
# 'schedule': timedelta(seconds=10), # change to `crontab(minute=0, hour=0)` if you want it to run daily at midnight
#},
#'apps.schedulers.tasks.update_eps': {
# 'task': 'apps.schedulers.tasks.update_eps',
# 'schedule': timedelta(minutes=5), # change to `crontab(minute=0, hour=0)` if you want it to run daily at midnight
#},
}