bugfix/SK-847 | Fixes timing issue in client status check #605
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
In TaskStream the client lastseen field is updated if it is older than 10s, and q.get has a timeout of 1s. This means that it could be up to 10.999... seconds between updates in a worst case scenario.
The client status update thread has a period of 10s, and the cutoff for counting a client as active is 10 s. So if you are unlucky, the the timing could be that the client was always seen last more than 10s ago in _list_active_clients (if it happens to always hit that small window between 10s and when the client's "lastseen" is updated), and will thus never be listed as online.
By changing the timeout of _deamon_thread_client_status to 5s, we should have an error of margin and avoid the above issue.