Spaces:
Sleeping
Sleeping
Fix: Preserving user_email in audio job status to prevent 403 errors
Browse files
app/routers/audio_router.py
CHANGED
|
@@ -94,7 +94,10 @@ async def analyze_async(
|
|
| 94 |
try:
|
| 95 |
# analyze_audio is synchronous and heavy, run it in a thread
|
| 96 |
result = await asyncio.to_thread(analyze_audio, audio_bytes, filename)
|
| 97 |
-
|
|
|
|
|
|
|
|
|
|
| 98 |
logger.info(f"Job complete: {job_id}")
|
| 99 |
|
| 100 |
# Persist to MongoDB
|
|
@@ -123,7 +126,10 @@ async def analyze_async(
|
|
| 123 |
import traceback
|
| 124 |
tb = traceback.format_exc()
|
| 125 |
logger.error(f"Job failed: {job_id}\n{tb}")
|
| 126 |
-
|
|
|
|
|
|
|
|
|
|
| 127 |
|
| 128 |
background_tasks.add_task(run)
|
| 129 |
return {"job_id": job_id, "status": "processing"}
|
|
|
|
| 94 |
try:
|
| 95 |
# analyze_audio is synchronous and heavy, run it in a thread
|
| 96 |
result = await asyncio.to_thread(analyze_audio, audio_bytes, filename)
|
| 97 |
+
if job_id in job_store:
|
| 98 |
+
job_store[job_id].update({"status": "complete", "result": result})
|
| 99 |
+
else:
|
| 100 |
+
job_store[job_id] = {"status": "complete", "result": result, "user_email": user_email}
|
| 101 |
logger.info(f"Job complete: {job_id}")
|
| 102 |
|
| 103 |
# Persist to MongoDB
|
|
|
|
| 126 |
import traceback
|
| 127 |
tb = traceback.format_exc()
|
| 128 |
logger.error(f"Job failed: {job_id}\n{tb}")
|
| 129 |
+
if job_id in job_store:
|
| 130 |
+
job_store[job_id].update({"status": "error", "error": str(e)})
|
| 131 |
+
else:
|
| 132 |
+
job_store[job_id] = {"status": "error", "error": str(e), "user_email": user_email}
|
| 133 |
|
| 134 |
background_tasks.add_task(run)
|
| 135 |
return {"job_id": job_id, "status": "processing"}
|