Repository navigation
feat(backend):(do not merge this!!!!!!) add asynchronous audio processing jobs - #1074
Open
nandu1231239 wants to merge 4 commits into
Open
nandu1231239 wants to merge 4 commits into
nandu1231239 wants to merge 4 commits into
Conversation
AshanVimodh
requested changes
Sep 23, 2026
AshanVimodh
left a comment
Collaborator
There was a problem hiding this comment.
Requesting changes - a few things need addressing before this merges:
Blocking:
This branch conflicts with main (25 commits behind), in app/main.py. Please rebase/merge main and resolve.
Logic issues (not fixed by resolving the conflict - these are all in the new audio_jobs.py files):
- queue_audio_job does the file write and two Mongo inserts (AudioUploads.insert_one, audio_jobs.create_job) synchronously inside an async def handler, with no asyncio.to_thread. engine.py's event persistence explicitly moves Mongo work off the event loop for this reason (so open WebSocket clients stay responsive) - worth following the same pattern here.
- process_job only catches (OSError, MultiModalPredictionError). Any other exception during prediction propagates uncaught out of the background task, leaving the job stuck in "processing" forever with no error recorded and no way to retry it (retry only works on "failed" jobs).
- If AudioUploads.insert_one succeeds but audio_jobs.create_job fails, the uploaded file gets deleted but the AudioUploads document is left behind - an orphaned metadata record pointing at a file that no longer exists.
- An invalid job_id on POST /audio/jobs/{job_id}/retry returns 409 "Only failed jobs can be retried" instead of 400 "Invalid job ID", since retry_job's _job_id() raises ValueError for both cases and the router's except ValueError maps it to 409 regardless of cause.
Worth discussing before merge:
This adds an in-process job mechanism via FastAPI's BackgroundTasks. C1 (#1009/#1048) is building a separate Redis/RQ-backed job queue. If both land, we'd have two different background-job patterns in the codebase - worth agreeing which one is canonical.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.