Repository navigation
Fix statistics hang on DST fall-back day - #24
Closed
mschlicht-tt wants to merge 1 commit into
Closed
mschlicht-tt wants to merge 1 commit into
mschlicht-tt wants to merge 1 commit into
Conversation
split_into_days advanced by a fixed 24 hours and then rounded down to the start of the day. On a 25-hour day (end of daylight saving time, e.g. 25 October 2026 in Europe/Berlin) that landed on the same day again, so the loop never ended and kept growing the result list. Any range containing such a day hung: Year always, Month in October. Step by calendar date instead, like get_range does for LAST. Fixes #21 Co-Authored-By: Claude <noreply@anthropic.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.
Fixes #21
Problem
split_into_daysadvanced by a fixed 24 hours and then rounded down to the start of the day. On a 25-hour day (end of daylight saving time, e.g. 25 October 2026 in Europe/Berlin),00:00 + 24his23:00on the same day, which rounds back to00:00. The cursor never moved, so the loop ran forever and the result list kept growing. That's the 100% CPU, the growing memory, and the Streamlit server freezing for everyone.Any range containing such a day was affected: Year always, Month only in October (the "got stuck on one month once" from the report). The spring transition (23-hour day) was harmless, and that was the only case the existing tests covered.
Fix
Step by calendar date instead and take each boundary from
day_range(day + 1), the same approachget_rangealready uses forLAST. The now-unusedDAY_MSimport is removed.Tests
test_split_into_days_handles_dst_fall_back(with and without a start-of-day shift): October 2026 has 31 days, 25 October is 25 hours long, 2026 has 365 days.time.tzset, so it is skipped on Windows and runs in CI. Its assertions were checked by hand on a Windows machine set to Berlin time.pytest: 119 passed, 11 skipped.flake8: clean.Who to blame
Claude Code did this whole thing on its own: the investigation, the reproduction, the fix, the tests and this description. @mschlicht-tt only asked for it and takes no responsibility for any mischief in here. If something is wrong, blame the bot.
🤖 Generated with Claude Code