tests
This commit is contained in:
parent
b329811875
commit
03541e2f37
|
@ -22,30 +22,30 @@ def check_existing_download_task(track):
|
||||||
if models.Upload.objects.filter(
|
if models.Upload.objects.filter(
|
||||||
track=track,
|
track=track,
|
||||||
import_status__in=["pending", "finished"],
|
import_status__in=["pending", "finished"],
|
||||||
|
third_party_provider="archive-dl",
|
||||||
).exists():
|
).exists():
|
||||||
logger.info("Upload for this track already exist or is pending. Stopping task.")
|
raise Exception(
|
||||||
return
|
"Upload for this track already exist or is pending. Stopping task."
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def check_last_third_party_queries(track, count):
|
def check_last_third_party_queries(track, count):
|
||||||
# 15 per minutes according to their doc = one each 4 seconds
|
# 15 per minutes according to their doc = one each 4 seconds
|
||||||
time_threshold = timezone.now() - timedelta(seconds=5)
|
time_threshold = timezone.now() - timedelta(seconds=5)
|
||||||
if models.Upload.objects.filter(
|
if models.Upload.objects.filter(
|
||||||
track=track,
|
|
||||||
third_party_provider="archive-dl",
|
third_party_provider="archive-dl",
|
||||||
import_status__in=["pending", "finished"],
|
import_status__in=["pending", "finished"],
|
||||||
creation_date__gte=time_threshold,
|
creation_date__gte=time_threshold,
|
||||||
).exists():
|
).exists():
|
||||||
logger.info(
|
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
|
count += 1
|
||||||
if count > 3:
|
if count > 3:
|
||||||
logger.info(
|
raise Exception(
|
||||||
"Probably too many archivedl tasks are queue, stopping this task"
|
"Probably too many archivedl tasks are queue, stopping this task"
|
||||||
)
|
)
|
||||||
return
|
|
||||||
check_last_third_party_queries(track, count)
|
check_last_third_party_queries(track, count)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue