use cache locks

This commit is contained in:
2019-11-24 17:07:19 +03:00
parent 7257ea3327
commit 71d7ea7147
4 changed files with 32 additions and 9 deletions

View File

@@ -1,9 +1,9 @@
import traceback
import sentry_sdk
from celery.exceptions import Reject
from celery_once import QueueOnce
from django.utils import timezone
from django.core.cache import cache
from telebot import TeleBot
from djconfig import config
@@ -14,7 +14,7 @@ from config.celery import app
def check_feeds():
from feeds.models import Feed
feeds = Feed.objects.filter(lock=False)
feeds = Feed.objects.all()
enqueued = []
for feed in feeds:
if feed.run_check():
@@ -47,5 +47,4 @@ def execute_feed(feed_pk):
traceback.print_exc()
finally:
if feed:
feed.lock = False
feed.save()
cache.delete(feed.lock_key)