retry for tasks
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
Silver Ghost 2023-02-10 11:41:36 +03:00
parent 5c37ae78ff
commit 8b4796e5d1
No known key found for this signature in database
2 changed files with 8 additions and 10 deletions

View File

@ -9,26 +9,22 @@ from later42.libs.content import get_content
from later42.models.article import Article from later42.models.article import Article
from later42.models.urls import URL from later42.models.urls import URL
AIRBRAKE_PROJECT_ID = os.getenv('AIRBRAKE_PROJECT_ID', None) AIRBRAKE_PROJECT_ID = os.getenv("AIRBRAKE_PROJECT_ID", None)
AIRBRAKE_PROJECT_KEY = os.getenv('AIRBRAKE_PROJECT_KEY', None) AIRBRAKE_PROJECT_KEY = os.getenv("AIRBRAKE_PROJECT_KEY", None)
if AIRBRAKE_PROJECT_ID is not None and AIRBRAKE_PROJECT_KEY is not None: if AIRBRAKE_PROJECT_ID is not None and AIRBRAKE_PROJECT_KEY is not None:
notifier = pybrake.Notifier( notifier = pybrake.Notifier(project_id=AIRBRAKE_PROJECT_ID, project_key=AIRBRAKE_PROJECT_KEY, environment="celery")
project_id=AIRBRAKE_PROJECT_ID,
project_key=AIRBRAKE_PROJECT_KEY,
environment="celery"
)
patch_celery(notifier) patch_celery(notifier)
@shared_task() @shared_task(bind=True, max_retries=3, default_retry_delay=60)
def get_url_content_task(url, user_id): def get_url_content_task(url, user_id):
data = get_content(url)
user = User.objects.get(pk=int(user_id)) user = User.objects.get(pk=int(user_id))
url_object = URL(url=url, user=user) url_object = URL(url=url, user=user)
url_object.save() url_object.save()
data = get_content(url)
article = Article.objects.create(url=url_object) article = Article.objects.create(url=url_object)
article.content = data.article_html article.content = data.article_html
article.title = data.title article.title = data.title

View File

@ -1,3 +1,5 @@
-r requirements.txt
black black
isort isort
pylint pylint