-
Notifications
You must be signed in to change notification settings - Fork 8
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
Add error handling to flatpak_system_updates getter #44
base: main
Are you sure you want to change the base?
Conversation
gave this a quick test, it crashes after checking repositories:
note: if you want to test it on your own system first make sure nobara-updater is updated otherwise it's self-update mechanism may overwrite your changes, after that copy nobara_sync.py to/as /usr/bin/nobara-sync |
Cheers, will actually test my code before updating this PR 😆 |
Alright, pushed changes that allow the updater to successfully run. This should test most of the code path of my changes, but I will continue to monitor until a Flatpak update comes up. I also tested disconnecting from the internet and running the updater, and as expected it deadlocks. Will need to add a "timeout" to stop the loop after a few attempts. |
system_installation needs to be deleted manually using del for cleanup to occur. Nobara-Project#44 added a context manager in 9709fbc however did not properly clean up refcount. This change removes spurious references, and reintroduces `del` where required.
Have resolved everything I set out to do, ready for code review. I fixed the deadlock by simply re-raising any errors. This restores the same behaviour as the latest release of All references to Code has been tested in the non-updating path as of 977a17d, and the updating path as of 6ac0ff4, and found working on my machine. The changes between those commits are so small it is unlikely any error was introduced, and the context manager is run on both code paths regardless. |
Fixes #43.
The only "new" code is the block:
I ended up using the with statement to reduce repeated code. However, you may find it simpler to either:
flatpak_system_updates
is used@contextmanager
decorator fromcontextlib
to use a "function" instead of a "class"I also ended up making the naming more consistent between the two functions that used the
flatpak_system_updates
variable.You may also want to add some sort of timeout to the loop to prevent infinite blocking (e.g. if the user runs
nobara-sync
with no internet I feel like the error would not go away)Need to verify that
del self.system_installation
actually works and doesn't introduce a memory leak.No code quality guideline was provided so I used my rusty PEP-8 muscle memory. Seems to all look close enough to the existing code.
Also, complete disclaimer, this code is untested as I do not have a build environment nor can I reliably reproduce the error. Reading through, unless stated above I don't see any issues but the lack of testing is still a concern.