From eddec10f9843987f87b50671e2201fdafc98555a Mon Sep 17 00:00:00 2001 From: Ludwig Kristoffersson Date: Sun, 17 Sep 2023 20:42:36 +0200 Subject: [PATCH] address race conditions causing youtube lectures to sometime fail --- jobs/tasks/lecture/classify_video.py | 1 + jobs/tasks/lecture/create_description.py | 1 + jobs/tasks/lecture/fetch_metadata.py | 1 + 3 files changed, 3 insertions(+) diff --git a/jobs/tasks/lecture/classify_video.py b/jobs/tasks/lecture/classify_video.py index 9a09b355..5003a463 100644 --- a/jobs/tasks/lecture/classify_video.py +++ b/jobs/tasks/lecture/classify_video.py @@ -103,6 +103,7 @@ def job(lecture_id: str, language: str): logger.info(f'response from openAI: {response}') + lecture.refresh() lecture.approved = category_is_ok lecture.save() diff --git a/jobs/tasks/lecture/create_description.py b/jobs/tasks/lecture/create_description.py index 258cf300..e53522da 100644 --- a/jobs/tasks/lecture/create_description.py +++ b/jobs/tasks/lecture/create_description.py @@ -37,6 +37,7 @@ def job(lecture_id: str, language: str): analysis_id=analysis.id, ) + lecture.refresh() lecture.description = response lecture.save() diff --git a/jobs/tasks/lecture/fetch_metadata.py b/jobs/tasks/lecture/fetch_metadata.py index 71a7c7d0..83514c28 100644 --- a/jobs/tasks/lecture/fetch_metadata.py +++ b/jobs/tasks/lecture/fetch_metadata.py @@ -37,6 +37,7 @@ def job(lecture_id: str, language: str): else: raise ValueError(f'unknown source {lecture.source}') + lecture.refresh() lecture.title = title lecture.date = date lecture.group = group