-
Notifications
You must be signed in to change notification settings - Fork 152
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
Move BootLoaderConfig to context manager #2438
Conversation
Change the BootLoaderConfig class to be a context manager. All code using BootLoaderConfig was updated to the following with statement: with BootLoaderConfig.new(...) as bootloader_config: bootloader_config.some_member() This is related to Issue #2412
c830c19
to
d209a57
Compare
I created a Staging release with this patch... waiting for the integration tests to complete |
All tests passing, open for review :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be cleaner if the BootLoaderConfigBase
would use a contextlib.ExitStack
, as the volume_mounts
are already context managers
The reason why I did not push it into an ExitStack was because I think the elements of the ExitStack will disappear one after the other when we go forward moving the other classes into context managers. With each follup pull request my plan is to come more and more into that nested structure of context managers which will reduce the existing ExitStack until we reach the point where it is empty. The current implementation of some builders keeps resources active for way too long. BootLoaderConfig is one example. It was created super early and kept until the end of the complete build process. But within that process there is only one time where it actually operates and depending on the bootloader mounts stuff, does its bootloader config job and should now free the resources but it holds it too long. One of the nice effects of moving into the context managers is to find out how to release as early as possible. That's why I did not use the ExitStack because for the BootLoaderConfig I knew when I need it and when I can release. Hope this makes sense to you too ? |
Well, the idea of the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, I've added two small nit-picky comments
Change the BootLoaderConfig class to be a context manager. All code using BootLoaderConfig was updated to the following with statement:
This is related to Issue #2412