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

TypeError: unsupported operand type #8

Closed
chrishat34 opened this issue Feb 21, 2022 · 5 comments
Closed

TypeError: unsupported operand type #8

chrishat34 opened this issue Feb 21, 2022 · 5 comments

Comments

@chrishat34
Copy link

error-2022-02-21_19-37-15
error-2022-02-21_19-37-15.txt

@2e0byo
Copy link
Owner

2e0byo commented Feb 21, 2022

oops. Should be elapsed.seconds. Will fix.

@chrishat34
Copy link
Author

as this:
subtract = elapsed.seconds if elapsed else 0
#jch added .seconds
return max(self.period * 60 - elapsed.seconds, 0)

@2e0byo
Copy link
Owner

2e0byo commented Feb 22, 2022

Yes exactly. Madly busy atm: if you PR that I'll merge it. Otherwise I'll get at the codebase in a few days. This is where YADC suffers from the lack of a decent testsuite: that's the kind of typo which really should be been caught earlier...

@2e0byo 2e0byo closed this as completed in 418e20c Mar 3, 2022
@2e0byo
Copy link
Owner

2e0byo commented Mar 4, 2022

Note that I was not quite right:

        subtract = elapsed.seconds if elapsed else 0
        return max(self.period * 60 - subtract, 0)

The first line works out how much to subtract to take into account the runtime of the last run, ignoring elapsed if it wasn't passed (it's optional); the second returns how many seconds to sleep to make up the required time, capping the duration at zero since we can't go back in time if the run took longer than it should have.

The solution above (elapsed.seconds) will fail if elapsed is not passed. I believe all the code in this repo actually does pass it, so the issue is trivial.

@chrishat34
Copy link
Author

nice one - thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants