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

🐛 | GenericMultiTimerClass broken #2386

Closed
hoelger opened this issue Jun 19, 2024 · 4 comments · Fixed by #2332
Closed

🐛 | GenericMultiTimerClass broken #2386

hoelger opened this issue Jun 19, 2024 · 4 comments · Fixed by #2332
Labels
bug future3 Relates to future3 development needs triage

Comments

@hoelger
Copy link

hoelger commented Jun 19, 2024

Version

3.5.3

Branch

future3/main

OS

Ubuntu 22.04

Pi model

Laptop

Hardware

No response

What happened?

  1. https://github.com/MiczFlor/RPi-Jukebox-RFID/blob/future3/main/src/jukebox/jukebox/multitimer.py#L249
    self._function = self._callee(*self.class_args, iterations=self._iterations, **self.class_kwargs)
    Instead of modifying the function call, so that later self._function can be called, here the function is already executed. In my case the return value is None, so later the MultiTimer tries to call none, and the program dies.

  2. GenericMultiTimerClass tries to pass on the paramter iterations and MultiTimer tries to pass on parameter iteration so this clashes.

Should those two classes be interchangeable or not? I don't get the value of GenericMultiTimerClass because you can build just the same thing by simply using the MultiTimer so my cleanest suggestion is: Delete the GenericMultiTimerClass.

If you want to keep it, here's a fix that worked for me, on first shallow testing:
FixGenericMultiTimerClass.patch.txt

Logs

No response

Configuration

No response

More info

No response

@hoelger hoelger added bug future3 Relates to future3 development needs triage labels Jun 19, 2024
@hoelger
Copy link
Author

hoelger commented Jun 19, 2024

Also see typos in the same file:
typo.patch.txt

@pabera
Copy link
Collaborator

pabera commented Jun 20, 2024

Thanks @hoelger .. In which situation did you call this function. I am currently working on a PR to implement the timers. You did not use this branch, correct? #2332

@hoelger
Copy link
Author

hoelger commented Jun 20, 2024

Ah sorry, yes, I did not thoroughly look through other issues nor the state on development. So no, I just used this functionality on top of future3/main.

@s-martin s-martin linked a pull request Nov 5, 2024 that will close this issue
@pabera
Copy link
Collaborator

pabera commented Nov 9, 2024

I wanted to come back to this again. Thank you for the detailed review initially!

Thank you for the detailed review! You've identified two significant issues:

  1. You're absolutely right about the function execution bug. The current code executes self._callee immediately instead of storing it for later execution. I will fix this here feat: Add Idle Shutdown Timer support #2332
  2. The naming conflict between iterations/iteration parameters is indeed problematic and could cause unexpected behavior.

I disagree with your assessment about GenericMultiTimerClass as we will need this in same specific use cases (e.g. IdleShutdown). I will add some documentation to explain the classes better

@pabera pabera closed this as completed Nov 9, 2024
pabera added a commit to hoffie/RPi-Jukebox-RFID that referenced this issue Nov 9, 2024
pabera added a commit that referenced this issue Nov 10, 2024
* feat: Add Idle Shutdown Timer support

This adds an optional idle shutdown timer which can be enabled
via timers.idle_shutdown.timeout_sec in the jukebox.yaml config.

The system will shut down after the given number of seconds if no
activity has been detected during that time. Activity is defined as:
- music playing
- active SSH sessions
- changes in configs or audio content.

Fixes: #1970

* refactor: Break down IdleTimer into 2 standard GenericMultiTimerClass and GenericEndlessTimerClass timers

* feat: Introducing new Timer UI, including Idle Shutdown

* refactor: Abstract into functions

* Adding Sleep timer / not functional

* Finalize Volume Fadeout Shutdown timer

* Fix flake8

* Fix more flake8s

* Fix small bugs

* Improve multitimer.py suggested by #2386

* Fix flake8

---------

Co-authored-by: pabera <1260686+pabera@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug future3 Relates to future3 development needs triage
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants