From 55a7bcc8748632b0c6b4ed0c9f51019ef52ddfe6 Mon Sep 17 00:00:00 2001 From: Eric Gullickson <16152721+ericgullickson@users.noreply.github.com> Date: Wed, 11 Feb 2026 20:06:03 -0600 Subject: [PATCH] fix: Manual polling typo --- ocr/app/extractors/manual_extractor.py | 6 +++++- ocr/tests/test_manual_extractor.py | 3 +-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/ocr/app/extractors/manual_extractor.py b/ocr/app/extractors/manual_extractor.py index c2ed271..2f9fd6d 100644 --- a/ocr/app/extractors/manual_extractor.py +++ b/ocr/app/extractors/manual_extractor.py @@ -119,7 +119,11 @@ class ManualExtractor: f"Extraction complete: {len(schedules)} schedules in {processing_time_ms}ms" ) - update_progress(100, "Complete") + # Note: do NOT send 100% progress here. The caller sets status=COMPLETED + # after this returns. Because this runs in a thread executor and the + # progress callback uses run_coroutine_threadsafe (fire-and-forget), + # a 100% update here races with complete_manual_job() and can overwrite + # COMPLETED back to PROCESSING. return ManualExtractionResult( success=True, diff --git a/ocr/tests/test_manual_extractor.py b/ocr/tests/test_manual_extractor.py index adf39d0..24d9588 100644 --- a/ocr/tests/test_manual_extractor.py +++ b/ocr/tests/test_manual_extractor.py @@ -108,12 +108,11 @@ class TestNormalExtraction: extractor.extract(_make_pdf_bytes(), progress_callback=track_progress) - # Should have progress calls at 10, 50, 95, 100 + # Should have progress calls at 10, 50, 95 (100% is set by complete_manual_job) percents = [p for p, _ in progress_calls] assert 10 in percents assert 50 in percents assert 95 in percents - assert 100 in percents # Percents should be non-decreasing assert percents == sorted(percents)