fix: terminate interrupted parallel workers - #670
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthrough
Estimated code review effort: 2 (Simple) | ~10 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@fastembed/parallel_processor.py`:
- Around line 211-212: Update the emergency shutdown flow around
join_or_terminate to join every worker after process.terminate(), using the
existing timeout, before clearing self.processes. Extend both emergency-shutdown
tests to verify that each terminated worker receives the second join() call.
- Line 156: Reset ParallelWorkerPool.emergency_shutdown to False at the
beginning of start(), before creating new queues, so a reused pool performs
normal join_thread() cleanup after a prior early close. Add a test covering
sequential reuse of the same pool after early shutdown.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 3f807871-53de-4475-82bb-84eda11975a9
📒 Files selected for processing (2)
fastembed/parallel_processor.pytests/test_parallel_processor.py
There was a problem hiding this comment.
🧹 Nitpick comments (1)
tests/test_parallel_processor.py (1)
104-110: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick winAssert worker termination after pool reuse.
After
first_results.close(), this test checks the emergency flag and queue cancellation, but it does not checkfirst_process.terminate()or the boundedjoin()calls. A regression limited to a reused pool could leave the first worker alive and still pass this test. Add the worker lifecycle assertions used by the fresh-pool test.Proposed assertions
first_results.close() assert pool.emergency_shutdown is True + assert first_process.join.call_args_list == [call(timeout=1), call(timeout=1)] + first_process.terminate.assert_called_once_with() first_input_queue.cancel_join_thread.assert_called_once_with()🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/test_parallel_processor.py` around lines 104 - 110, Extend the reused-pool assertions after first_results.close() to verify first_process.terminate() was called and that its bounded join() calls match the fresh-pool test. Keep the existing emergency_shutdown and queue cancellation assertions unchanged, using the same lifecycle assertion pattern and timeout expectations already established for the fresh-pool case.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@tests/test_parallel_processor.py`:
- Around line 104-110: Extend the reused-pool assertions after
first_results.close() to verify first_process.terminate() was called and that
its bounded join() calls match the fresh-pool test. Keep the existing
emergency_shutdown and queue cancellation assertions unchanged, using the same
lifecycle assertion pattern and timeout expectations already established for the
fresh-pool case.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 5437ebdf-c331-4a07-a51e-3cae8d76b00d
📒 Files selected for processing (2)
fastembed/parallel_processor.pytests/test_parallel_processor.py
🚧 Files skipped from review as they are similar to previous changes (1)
- fastembed/parallel_processor.py
Summary
Testing
pytest -q tests/test_parallel_processor.py tests/test_common.py(4 passed)ordered_map()close returns and leaves zero tracked processesruff check fastembed/parallel_processor.py tests/test_parallel_processor.pyruff format --check fastembed/parallel_processor.py tests/test_parallel_processor.pypytest --collect-only -q(92 tests collected)All Submissions
Closes #669