Fix empty range in terminate_pool_with_backoff making it a no-op#4784
Open
codewithfourtix wants to merge 2 commits intoaboutcode-org:developfrom
Open
Fix empty range in terminate_pool_with_backoff making it a no-op#4784codewithfourtix wants to merge 2 commits intoaboutcode-org:developfrom
codewithfourtix wants to merge 2 commits intoaboutcode-org:developfrom
Conversation
range(number_of_trials, 1) with number_of_trials=3 produces an empty range since the default step is +1 and 3 > 1. The retry loop body never executed, so on Windows pool termination with backoff never happened. Fix by using range(number_of_trials) to iterate correctly. Signed-off-by: codewithfourtix <codewithfourtix@gmail.com>
There was a problem hiding this comment.
Pull request overview
Fixes a Windows-only bug where terminate_pool_with_backoff() never executed its retry loop due to an empty range(), preventing process pool termination attempts after failures.
Changes:
- Corrects the retry loop range in
terminate_pool_with_backoff()so termination is attempted on Windows.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Ensure the retry loop actually executes and calls pool.terminate() at least once, and retries correctly on WindowsError. Prevents the old range(number_of_trials, 1) empty-range bug from regressing. Signed-off-by: codewithfourtix <codewithfourtix@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix
terminate_pool_with_backoffno-op loop on Windowsrange(number_of_trials, 1)evaluates torange(3, 1)which produces an empty sequence since the default step is+1. As a result, the retry loop never executes, makingterminate_pool_with_backoffa complete no-op on Windows — pool termination is never attempted on failure.Tasks
Run [tests](https://scancode-toolkit.readthedocs.io/en/latest/contribute/contrib_dev.html#running-tests) locally to check for errors.