-
Notifications
You must be signed in to change notification settings - Fork 421
Fix iteration over streamers list to safely remove non-existent strea… #721
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes a critical bug where the application would crash when a streamer's account was deleted or banned by implementing proper exception handling for StreamerDoesNotExistException.
- Adds try-catch blocks around streamer data loading operations
- Implements safe list iteration using slice copying to avoid modification-during-iteration issues
- Logs informative messages and removes non-existent streamers instead of crashing
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| # 2. Check if streamers are online | ||
| # 3. DEACTIVATED: Check if the user is a moderator. (was used before the 5th of April 2021 to deactivate predictions) | ||
| for streamer in self.streamers: | ||
| for streamer in self.streamers[:]: # Create a copy of the list to safely remove items during iteration |
Copilot
AI
Sep 10, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Creating a shallow copy of the entire streamers list on every iteration is inefficient. Consider iterating backwards through the list using for i in range(len(self.streamers) - 1, -1, -1): and accessing self.streamers[i], then removing by index to avoid the copy overhead.
| self.twitch.load_channel_points_context( | ||
| self.streamers[index] | ||
| ) | ||
| for streamer in self.streamers[:]: # Create a copy of the list to safely remove items during iteration |
Copilot
AI
Sep 10, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Creating a shallow copy of the entire streamers list on every 30-minute refresh is inefficient. Consider iterating backwards through the list using for i in range(len(self.streamers) - 1, -1, -1): and accessing self.streamers[i], then removing by index to avoid the copy overhead.
…tional cryptography installation from Dockerfile
Description
This pull request addresses a critical bug where the application would crash when a streamer no longer exists. Previously, when a streamer's account was deleted or banned, the
StreamerDoesNotExistExceptionwas not properly handled, causing the entire application to terminate unexpectedly.The fix implements proper exception handling in the
runmethod ofTwitchChannelPointsMiner.pyat two critical points:When a
StreamerDoesNotExistExceptionis caught, the application now logs an informative message and removes the non-existent streamer from the list, allowing the application to continue running with the remaining streamers.Fixes # (issue)
Type of change
How Has This Been Tested?
The fix has been tested by simulating the scenario where a streamer no longer exists. This was done by:
Test configuration:
Checklist: