Skip to content
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

Timer: Remove periodic() and timeout() #264

Merged
merged 7 commits into from
Jan 16, 2024

Conversation

llucax
Copy link
Contributor

@llucax llucax commented Jan 16, 2024

The names are just too confusing and we'll never find a name that can convey all the intricacies of timers in the async world, so it is better to just remove periodic() and timeout() and force users to pass the missing ticks policies manually.

Fixes #253.

@llucax llucax requested a review from a team as a code owner January 16, 2024 09:15
@llucax llucax requested a review from Marenz January 16, 2024 09:15
@github-actions github-actions bot added part:docs Affects the documentation part:tests Affects the unit, integration and performance (benchmarks) tests part:synchronization Affects the synchronization of multiple sources (`select`, `merge`) part:core Affects the core types (`Sender`, `Receiver`, exceptions, etc.) labels Jan 16, 2024
@llucax llucax requested a review from shsms January 16, 2024 09:18
@llucax llucax self-assigned this Jan 16, 2024
This quick start is provided to have a quick feeling of how to use this module, but
it is extremely important to understand how timers behave when they are delayed.

We recommned emphatically to read about [missed ticks and
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

recommned > recommend

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Copy link
Contributor

@Marenz Marenz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor typo

@@ -27,7 +27,7 @@ async def test_file_watcher(tmp_path: pathlib.Path) -> None:
expected_number_of_writes = 3

file_watcher = FileWatcher(paths=[str(tmp_path)])
timer = Timer.timeout(timedelta(seconds=0.1))
timer = Timer(timedelta(seconds=0.1), SkipMissedAndDrift())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you think SkipMissedAndDrift should be an instance created in the channel package, so that we don't have to specify the () to create an instance of the thing?

This was a bit confusing for me the first time I did this, because I was expecting to pass just the policy, not an object of the policy that I had to create.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The policies can have options, and SkipMissedAndDrift() have one (delay_tolerance). I think if we provide fixed instances with fixed options we'll eventually need another PR to remove them because they are still hiding the complexity :)

@shsms
Copy link
Contributor

shsms commented Jan 16, 2024

Although not strictly necessary, in this case it is easy to make all commits pass CI by just moving the first commit to near the end.

@llucax
Copy link
Contributor Author

llucax commented Jan 16, 2024

Although not strictly necessary, in this case it is easy to make all commits pass CI by just moving the first commit to near the end.

True, but I thought review-wise It makes more sense to start with the important change first, and then adapt the code to deal with that change. I'm trying to prioritize easy of review when splitting the commits.

I can move the commit if you prefer though...

Signed-off-by: Leandro Lucarella <[email protected]>
Having the note at the end, just before the Missed ticks and drifting
section starts doesn't make a lot of sense, it is better to warn the
user before they start reading.

Also change from a tip to an important information.

Signed-off-by: Leandro Lucarella <[email protected]>
These names proved to be too confusing for users. It seems like having
a short name that can convey all the intricacies of timers in the async
world is very difficult, so we better stop trying to hide the complexity
and force users to read about and use missed tick policies explicitly.

Signed-off-by: Leandro Lucarella <[email protected]>
Signed-off-by: Leandro Lucarella <[email protected]>
@llucax
Copy link
Contributor Author

llucax commented Jan 16, 2024

Updated to fix the typo and move the removal from the code to the end.

@llucax llucax enabled auto-merge January 16, 2024 10:52
@llucax
Copy link
Contributor Author

llucax commented Jan 16, 2024

Enabled auto-merging.

@llucax llucax added this pull request to the merge queue Jan 16, 2024
Merged via the queue into frequenz-floss:v1.x.x with commit 150bdf1 Jan 16, 2024
14 checks passed
@llucax llucax deleted the rm-timer-ctors branch January 16, 2024 11:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
part:core Affects the core types (`Sender`, `Receiver`, exceptions, etc.) part:docs Affects the documentation part:synchronization Affects the synchronization of multiple sources (`select`, `merge`) part:tests Affects the unit, integration and performance (benchmarks) tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Timer: Remove periodic() and timeout()
3 participants