Repository navigation
fix(gamestore): only remove inactive games and notify the chat - #118
Merged
Merged
Conversation
The stale game cleaner measured a game's age from its creation, so any game older than 10 minutes was removed, even while it was being played. The chat was never told, and the cleaner iterated the game dict from the job queue thread while handlers could modify it. Games now track their last activity (joining, starting, drawing, next player) and the cleaner removes games that have been inactive for 10 minutes. It iterates over a copy of the games and returns the removed chat ids, so the job can notify each chat with a translated message. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KouGQtM6VBedfBdNr8WFX5
d-Rickyy-b
force-pushed
the
claude/project-thread-gbpez2-stale-games
branch
from
October 8, 2026 21:40
9068308 to
3144087
Compare
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.
Requested by Rico · project thread
Before: the stale-game cleaner removed every game created more than 10 minutes ago, even games still being played. The chat wasn't told, so players' next button press just said "There is no created game!". The cleaner also iterated the game dict from the JobQueue thread while handlers could add or remove games, which can raise
RuntimeError: dictionary changed size during iteration.After: only games where nothing happened for 10 minutes are removed. The chat gets a message that the game ended because of inactivity and can
/starta new one.How:
BlackJackGamehas a newlast_activitytimestamp. It is updated when a player joins, the game starts, a card is drawn, or the turn moves to the next player.GameStore.cleanup_stale_gamescheckslast_activity, iterates over a copy of the games, and returns the removed chat ids.bot.pysends each of those chats the newgame_ended_inactivestring. I added English and German versions; other languages fall back to English. Send errors, such as when the bot was blocked, are logged and don't stop the loop.blackjackbot/tests/gamestore_test.pycover both cases: an inactive game is removed, and an old game that is still active is kept.🤖 Generated with Claude Code
https://claude.ai/code/session_01KouGQtM6VBedfBdNr8WFX5
Generated by Claude Code