Skip to content

feat(backend):(do not merge this!!!!!!) add asynchronous audio processing jobs - #1074

Open
nandu1231239 wants to merge 4 commits into
mainfrom
async_audio_processing
Open

nandu1231239 wants to merge 4 commits into
mainfrom
async_audio_processing

Conversation

@nandu1231239

Copy link
Copy Markdown
Collaborator

No description provided.

@AshanVimodh AshanVimodh left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@nandu1231239 nandu1231239 changed the title feat(backend): add asynchronous audio processing jobs feat(backend):(do not merge this!!!!!!) add asynchronous audio processing jobs Sep 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants