This commit is contained in:
Petitminion 2025-03-25 17:12:47 +01:00
parent 2c0451704f
commit bc0bd7f736
1 changed files with 7 additions and 7 deletions

View File

@ -22,30 +22,30 @@ def check_existing_download_task(track):
if models.Upload.objects.filter(
track=track,
import_status__in=["pending", "finished"],
third_party_provider="archive-dl",
).exists():
logger.info("Upload for this track already exist or is pending. Stopping task.")
return
raise Exception(
"Upload for this track already exist or is pending. Stopping task."
)
def check_last_third_party_queries(track, count):
# 15 per minutes according to their doc = one each 4 seconds
time_threshold = timezone.now() - timedelta(seconds=5)
if models.Upload.objects.filter(
track=track,
third_party_provider="archive-dl",
import_status__in=["pending", "finished"],
creation_date__gte=time_threshold,
).exists():
logger.info(
"Last archive.org query was too recent. Trying to wait 10 seconds..."
"Last archive.org query was too recent. Trying to wait 2 seconds..."
)
time.sleep(10)
time.sleep(2)
count += 1
if count > 3:
logger.info(
raise Exception(
"Probably too many archivedl tasks are queue, stopping this task"
)
return
check_last_third_party_queries(track, count)