This repository has been archived by the owner on Sep 8, 2024. It is now read-only.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Handle ntp sync in audioservice ready wait. Events (and python threading in general) don't use monotonic time and can be affected by an ntp sync.
The log from @krisgesling shows the following
Notice the timestamp difference on the two last entries. Between these the time jumped ~5 months which is longer than the 3 minute timeout on the wait. Likely (possibly/maybe) network connection was established during this time adjusting the time and thus ending the Event wait.
This adds logic to repeat the wait if the monotonic time don't agree with the event timeout.
How to test
It's sort of tricky to test in a good way. Firstly make sure the audioservice starts in normal circumstances (run the service, add a delay in loading services and make sure the result of the wait is as expected).
Secondly try to repeat the actual issue using the
date
command:time.sleep(300)
on L204sudo date +%T -s "HH:MM:SS"
with a suitable clock time in the futureMake sure the service doesn't exit directly, but waits the expected 3 minutes before shutting down.
Contributor license agreement signed?
CLA [ ] (Whether you have signed a CLA - Contributor Licensing Agreement