Improve MPI lifecycle management in PyOmega_h - #233
Conversation
|
I don't understand the consequences of adding/using Can we just document that the mesh needs to be deleted before the library goes out of scope? |
|
I'm not against just documenting the issue since this only involved |
I agree with this idea of |
|
Agreed; initialize+finalize is also my preference. |
|
@cwsmith I think I could define the OmegaHLibrary at the PyOmega_h module level as a singleton, which seems to avoid the error. User can get the lib from the module directly with |
|
This seems like a better compromise than |
|
This PR addresses and should close Issue #236 |
|
/runtests |
|
Test Results:
|
In python API, the library object owns the MPI lifecycle, but the mesh needs the library to remain alive as long as the mesh exists. Python doesn’t handle this object lifetime relationship correctly when exiting, causing an MPI error after executing the main program. This PR applied the
keep_alivefeature from pybind11 to resolve the issue.