Fixes unexpected segfaults or faulty logs during the Python session shutdown.
This was mostly due to an incorrect order in the shutdown routines and some of them not being triggered due to dangling references. In particular, a PyModuleDef's m_free attribute will not be called if there are still some references to the module.
(cc @bathal1)
Testing
No new tests were added - capturing the corrected behavior is too complex in pytest.
Description
Fixes unexpected segfaults or faulty logs during the Python session shutdown.
This was mostly due to an incorrect order in the shutdown routines and some of them not being triggered due to dangling references. In particular, a
PyModuleDef
'sm_free
attribute will not be called if there are still some references to the module.(cc @bathal1)
Testing
No new tests were added - capturing the corrected behavior is too complex in pytest.