Fix list modification during iteration in wait_for_threads_to_finish#1471
Fix list modification during iteration in wait_for_threads_to_finish#1471juandiego-bmu wants to merge 1 commit intoOWASP:masterfrom
Conversation
Replace threads.remove(thread) inside for loop with a list comprehension slice assignment. Removing elements during iteration shifts the iterator and can skip threads that just finished. Fixes OWASP#1465
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
Summary by CodeRabbit
WalkthroughThe Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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.
Pull request overview
This PR fixes unsafe mutation of the threads list during iteration in wait_for_threads_to_finish, preventing skipped elements when multiple threads/processes finish between checks.
Changes:
- Replace in-loop
threads.remove(thread)while iterating with an in-place slice assignment that filters to alive items (threads[:] = [...]).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@juandiego-bmu please follow the contributor guidelines and PR template checks. It might be easier if you create a new clean PR which follows the guidelines and checks reference it here and close this PR. |
|
Closing to recreate with proper PR template and signed commits as requested by @securestep9. |
Summary
Replace
threads.remove(thread)insidefor thread in threadsloop with a list comprehension slice assignment.Removing elements during iteration shifts the iterator and can skip threads that just finished. Using
threads[:] = [t for t in threads if t.is_alive()]rebuilds the list safely.Split from #1466 as requested by @pUrGe12.
Fixes #1465