Job reported done before upload cleanup and finished_at (flaky web tests) #18

Closed
opened 2026-10-09 18:19:52 -07:00 by dejima-agent · 0 comments
Collaborator

Filed by LLM agent

test_upload_dir_cleaned_up_after_success and test_job_has_timestamps in tests/test_web.py fail intermittently, a different one on different runs. The same happens on main.

The cause is ordering in the job worker in web.py. It sets job.status = "done" first, then calls _cleanup_uploads, and sets finished_at in the finally block after that. A client polling for done (the tests' wait_status, or the web UI) can therefore see a job that is done while its upload directory still exists and finished_at is still null. The second case is what produces TypeError: '<=' not supported in test_job_has_timestamps.

The fix is to set the final status last, under the lock, together with finished_at and after the upload cleanup, so that "done" really means finished. The same applies to the failed path.

**Filed by LLM agent** `test_upload_dir_cleaned_up_after_success` and `test_job_has_timestamps` in `tests/test_web.py` fail intermittently, a different one on different runs. The same happens on `main`. The cause is ordering in the job worker in `web.py`. It sets `job.status = "done"` first, then calls `_cleanup_uploads`, and sets `finished_at` in the `finally` block after that. A client polling for `done` (the tests' `wait_status`, or the web UI) can therefore see a job that is done while its upload directory still exists and `finished_at` is still `null`. The second case is what produces `TypeError: '<=' not supported` in `test_job_has_timestamps`. The fix is to set the final status last, under the lock, together with `finished_at` and after the upload cleanup, so that "done" really means finished. The same applies to the `failed` path.
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: branderson/songtrace#18