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

Make arch_updates module more responsive to system updates #2215

Merged
merged 1 commit into from
Oct 13, 2023

Conversation

geoffliu
Copy link
Contributor

@geoffliu geoffliu commented Oct 4, 2023

The goal of this PR is that we want to invalidate the cached output of the arch_updates module after a system update. The gist of the approach is this:

  • remove cached_until and cache_timeout values, thus bypassing built-in caching of py3status
  • use module storage as a cache
  • if pacman.log has been updated, invalidate cache

This whole business of bypassing the built-in caching feels a bit dirty, but I'm not familiar with py3status's full module API to know if there's a better approach? @ultrabug What do you think?

Also, now that the module can be more responsive, we can change the default of refresh interval to be longer without degrading user experience

@geoffliu geoffliu force-pushed the gl/arch-package-cache branch 4 times, most recently from 4a53386 to 1cb8eb2 Compare October 10, 2023 13:19
@geoffliu geoffliu force-pushed the gl/arch-package-cache branch from 1cb8eb2 to 4b0627a Compare October 10, 2023 13:21
@ultrabug ultrabug merged commit 24888b3 into ultrabug:master Oct 13, 2023
5 checks passed
@ultrabug
Copy link
Owner

I trust you as a module user and the logic LGTM thanks!

@geoffliu geoffliu deleted the gl/arch-package-cache branch October 14, 2023 14:52
Copy link
Contributor

@lasers lasers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for not reviewing this sooner.

Comment on lines +8 to +11
refresh_interval: interval (in seconds) between refreshing data from package
database or AUR. Note that this module may refresh sooner than the
specified interval, if pacman log is modified since the last refresh
time. (default 3600)
Copy link
Contributor

@lasers lasers Oct 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't be renamed just because it gets refreshed sooner. Modules get refreshed sooner all times via clicks, py3-cmd, i3, et cetera. This now ignore people's current cache_timeout setting too.

format = None
hide_if_zero = False
pacman_log_location = "/var/log/pacman.log"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Opinion) I'd like the module to just parse /etc/pacman.conf and grab the log location from there instead.

self.py3.storage_set(CACHE_KEY_TEXT, full_text)
self.py3.storage_set(CACHE_KEY_TIMESTAMP, time.time())

return {"full_text": full_text}
Copy link
Contributor

@lasers lasers Oct 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not using Arch right now, but this looks like arch_updates module may be constantly updated all times now... in order to avoid running updater command. Unconfirmed, but something to think about.

The better way just may be to document users to use this hook instead with py3-cmd refresh arch_updates along with either disabled cache_timeout = -1 or longer delay cache_timeout = 3600. https://archlinux.org/pacman/alpm-hooks.5.html

lasers added a commit to lasers/py3status that referenced this pull request Nov 2, 2023
lasers added a commit to lasers/py3status that referenced this pull request Jan 15, 2024
lasers added a commit to lasers/py3status that referenced this pull request Jan 18, 2024
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

Successfully merging this pull request may close these issues.

3 participants