use celerybeat

This commit is contained in:
2019-01-26 12:36:44 +03:00
parent 6a88f7da4b
commit ec01ab879f
8 changed files with 32 additions and 25 deletions

View File

@@ -1,17 +0,0 @@
from time import sleep
from django.core.management import BaseCommand
from feeds.models import Feed
class Command(BaseCommand):
def handle(self, *args, **options):
try:
while True:
feeds = Feed.objects.filter(lock=False)
for feed in feeds:
feed.run_check()
sleep(5)
except KeyboardInterrupt:
pass

View File

@@ -1,11 +1,17 @@
from pprint import pprint
from django.conf import settings
from celery_once import QueueOnce
from django.utils import timezone
from telebot import TeleBot
from djconfig import config
from config.celery import app
from feeds.models import Feed
@app.task(base=QueueOnce)
def check_feeds():
feeds = Feed.objects.filter(lock=False)
for feed in feeds:
feed.run_check()
@app.task()