Skip to content

Conversation

@Marenz
Copy link
Contributor

@Marenz Marenz commented Sep 17, 2024

80% ChatGPT-o1-preview, 20% me

@github-actions github-actions bot added part:docs Affects the documentation part:tests Affects the unit, integration and performance (benchmarks) tests part:tooling Affects the development tooling (CI, deployment, dependency management, etc.) labels Sep 17, 2024
@llucax
Copy link
Contributor

llucax commented Sep 18, 2024

I'm not convinced this belongs in this repo, and I'm not convinced by the interface either. Bad ChatGPT, bad!

Seriously, I would much rather make interval changable via reset() in the current timer, and build something on top of that instead of re-implementing the whole thing. All we need is a interval-reseteable timer and a container that gives you the next interval from a list of "scheduled timers", they can be completely decoupled.

If there is no such a container available yet, I would add it to https://github.com/frequenz-floss/frequenz-core-python/ instead.

What I envision is something like:

timer_scheduler = TimerScheduler()
timer_scheduler.add(...)

timer = Timer(timer_scheduler.next(), ...)

async for selected in select(timer, other):
    if selected_from(selected, timer):
        ...
        timer.reset(timer_scheduler.next())
    if selected_from(selected, other):
        ...
        timer_scheduler.add(...) # or timer_scheduler.remove(...)    
...

@Marenz
Copy link
Contributor Author

Marenz commented Sep 18, 2024

I'm not convinced this belongs in this repo, and I'm not convinced by the interface either. Bad ChatGPT, bad!

Well, I designed the interface and ChatGPT did a good job at it imo.
And I like it too.

What I envision is something like:

How would you propose to interrupt a scheduled timer that is currently in ready()'s await asyncio.sleep(..)?
Which task do we have to cancel?

@llucax
Copy link
Contributor

llucax commented Sep 18, 2024

How would you propose to interrupt a scheduled timer that is currently in ready()'s await asyncio.sleep(..)?
Which task do we have to cancel?

I guess you already answer it for yourself with #320 :)

@Marenz Marenz closed this Sep 19, 2024
@Marenz Marenz deleted the timer_scheduler branch September 19, 2024 09:24
github-merge-queue bot pushed a commit that referenced this pull request Sep 19, 2024
Ugly alternative to #320

>They eat our timers, our start_delays!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

part:docs Affects the documentation part:tests Affects the unit, integration and performance (benchmarks) tests part:tooling Affects the development tooling (CI, deployment, dependency management, etc.)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants