forked from 0x2620/pandora
update to new celery api
This commit is contained in:
parent
f71434a1ff
commit
9340c0e578
17 changed files with 103 additions and 65 deletions
|
|
@ -2,17 +2,22 @@
|
|||
|
||||
from datetime import timedelta, datetime
|
||||
|
||||
from celery.task import task, periodic_task
|
||||
from django.conf import settings
|
||||
|
||||
from app.utils import limit_rate
|
||||
from app.celery import app
|
||||
from celery.schedules import crontab
|
||||
|
||||
@periodic_task(run_every=timedelta(days=1), queue='encoding')
|
||||
@app.task(queue='encoding')
|
||||
def cronjob(**kwargs):
|
||||
if limit_rate('translations.tasks.cronjob', 8 * 60 * 60):
|
||||
load_translations()
|
||||
|
||||
@task(ignore_results=True, queue='encoding')
|
||||
@app.on_after_finalize.connect
|
||||
def setup_periodic_tasks(sender, **kwargs):
|
||||
sender.add_periodic_task(timedelta(days=1), cronjob.s())
|
||||
|
||||
@app.task(ignore_results=True, queue='encoding')
|
||||
def load_translations():
|
||||
from .models import load_itemkey_translations, load_translations
|
||||
load_translations()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue