Conversation
|
@rodrigogiraoserrao I just pushed tests and a fix (to make sure Thanks! |
When subtracting time clamped n to 0, sleep_until was adjusted by the full 30 seconds instead of the actual amount subtracted. Now sleep_until is only adjusted by the actual change to n. Also use None instead of 0 as the pause_start sentinel for clarity.
- Fix wrong reasoning in line count comment (test_main.py) - Remove stale "20 chunks" and "chunked 1-second" references - Fix "10x" drift comment to show actual values - Fix "fewer sleep iterations" to "seconds are skipped entirely" - Assert extreme drift test ends at 0 - Assert pause test displays 0
|
@treyhunner looks good to me. I pulled your changes and ran a 1m timer together with a stopwatch on my phone. They ran in sync. |
|
Great. Thanks for the PR @rodrigogiraoserrao! I'll put a new release on PyPI shortly. |
Well, it was more or less what you'd call a “poisoned gift” in Portuguese. It was more work for you than the trouble it saved you 😅. But thanks for your work on the tests. |
|
The tests needed refactoring anyway. 😉 And an LLM did most of the tedious parts anyway. Thanks for reporting the bug and making a fix! |
Fixes #219.
This fixes the drift I mentioned in #219 by using the real time that is elapsed during sleeps and in calling other functions. This change breaks some of the current tests because some of the tests relied on the exact looping structure. I did not fix the broken tests. I did test the app locally before and after the fix. A 60s timer takes ~66s on my computer before the fix and it takes ~60s after the fix.
I understand that, given I didn't touch the tests, you may close this PR. I just opened it either way to share a reference implementation for a fix.