-
Notifications
You must be signed in to change notification settings - Fork 341
[Helper] Added cleanup callback #4828
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
[Helper] Added cleanup callback #4828
Conversation
|
[ci-depends-on] detected during build #1. To unlock the merge button, you must
|
|
[ci-build][with-all-tests] |
|
[ci-depends-on] detected during build #2. To unlock the merge button, you must
|
|
[ci-depends-on] detected during build #3. To unlock the merge button, you must
|
|
[ci-depends-on] detected during build #4. To unlock the merge button, you must
|
| if (!s_cleanedUp) | ||
| { | ||
|
|
||
| system::PluginManager::getInstance().cleanup(); |
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 wonder if Sofa.Helper is the right place to call a plugin clean up...
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.
It was asked by @fredroy and it makes sens because the plugin manager belongs to Sofa.Helper
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.
Yes, but your goal is to clean up plugins, not the plugin manager. For example, you will clean up SofaPython3 inside the Sofa.Helper cleanup function. I am not saying it is not the right thing to do, I am just questioning ...
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.
My first though was to put it at the very end of the main function, both are justifiable. But I guess that conceptually, the cleanup order shouldn't matter, the simulation is over, we are just cleaning after us...
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.
Why not inside the destructor of PluginManager ? (if it is ever called 🥴)
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.
We don't want it to be in a static instance, this fix aims at cleaning the static cache before the dynamically allocated python interpreter... So no, it is necessary to have it explicitly called.
79e641d to
4d74bf7
Compare
|
[ci-depends-on] detected during build #5. To unlock the merge button, you must
|
|
@damienmarchal , discussions during the SOFA-dev meeting lead to a question over the developed design and your opinion is needed. The problem was that some scenes tests where crashing at exit. This is due to the SofaPython3 cache ( To fix it, following pybind11 suggestions I've added a member to the module Sofa.Core that insured that the cleanup is called while the interpreter is still alive (see the PR sofa-framework/SofaPython3#425). But is was not enough because the interpreter is not cleaned correctly either : the static method "Release" of SofaPython3, in charge of cleaning up python and deleting the interpreter was never called when launching scene in runSofa. This lead to the need of cleaning up explicitly the plugin before exiting the main function. This design was not liked by every dev, some wanting a Raii-like cleanup, in the destructor of some member, which is in my mind not possible because the interpreter instance is static in the SofaPython3 plugin and thus we have no guaranty that it would not be deleted before any other static member. |
|
[ci-depends-on] detected during build #6. To unlock the merge button, you must
|
|
[ci-build][with-all-tests] |
|
[ci-depends-on] detected during build #6. To unlock the merge button, you must
|
4d74bf7 to
2870d8d
Compare
|
[ci-depends-on] detected during build #7. To unlock the merge button, you must
|
2870d8d to
de0dd56
Compare
|
[ci-depends-on] detected during build #9. To unlock the merge button, you must
|
|
[ci-depends-on] detected during build #10. To unlock the merge button, you must
|
|
[ci-depends-on] detected during build #11. To unlock the merge button, you must
|
|
[ci-build][with-all-tests][force-full-build] |
This pr aims at fixing the crash on exit for some python scene. It was due to the cache of the Sofa python module not being cleaned up correctly (deleted after the interpreter). This is corrected here by insuring that the interpreter is correcty released through cleanup callback (see the SofaPython3 pr for more insights)
By submitting this pull request, I acknowledge that
I have read, understand, and agree SOFA Developer Certificate of Origin (DCO).
Reviewers will merge this pull-request only if