formatting / RQ tuning
This commit is contained in:
@@ -11,6 +11,7 @@ from utils.rip_background import bulk_download
|
||||
from lyric_search.sources import private
|
||||
from pydantic import BaseModel
|
||||
|
||||
|
||||
class ValidBulkFetchRequest(BaseModel):
|
||||
track_ids: list[int]
|
||||
|
||||
@@ -119,7 +120,13 @@ class RIP(FastAPI):
|
||||
}
|
||||
)
|
||||
track_ids = data.track_ids
|
||||
job = self.task_queue.enqueue(bulk_download, track_ids)
|
||||
job = self.task_queue.enqueue(
|
||||
bulk_download,
|
||||
args=(track_ids,),
|
||||
timeout=3600,
|
||||
failure_ttl=86400,
|
||||
result_ttl=86400,
|
||||
)
|
||||
self.redis_conn.lpush("enqueued_job_ids", job.id)
|
||||
return JSONResponse(
|
||||
content={
|
||||
@@ -150,7 +157,7 @@ class RIP(FastAPI):
|
||||
"""List all jobs in the queue (queued + finished, if result_ttl allows)"""
|
||||
jobs_info = []
|
||||
|
||||
# 1️⃣ Jobs still in the queue (pending)
|
||||
# Jobs still in the queue (pending)
|
||||
for job in self.task_queue.jobs:
|
||||
jobs_info.append(
|
||||
{
|
||||
@@ -162,7 +169,7 @@ class RIP(FastAPI):
|
||||
}
|
||||
)
|
||||
|
||||
# 2️⃣ Started/running jobs tracked via enqueued_job_ids
|
||||
# Started/running jobs tracked via enqueued_job_ids
|
||||
job_ids = self.redis_conn.lrange("enqueued_job_ids", 0, -1)
|
||||
for jid_bytes in job_ids: # type: ignore
|
||||
jid = jid_bytes.decode()
|
||||
|
Reference in New Issue
Block a user