Prevent module reinitialisation with multi-phase init by AA-Turner · Pull Request #1978 · coveragepy/coveragepy
Sorry for the crossed wires. I was referring to this note:
All modules created using multi-phase initialization are expected to support sub-interpreters, or otherwise explicitly signal a lack of support. This is usually achieved by isolation or blocking repeated initialization, as above. A module may also be limited to the main interpreter using the Py_mod_multiple_interpreters slot.
Per that same section, sharing Python objects between module instances would likely cause crashes or undefined behavior.. The side effect of the explicit error is that deleting the module from sys.modules and then re-importing it is expected to & will fail, as the import system attempts to re-initialise it in the same process. Clearly unwanted behaviour here, though.
Would importlib.reload work instead of deleting modules from sys.modules? That function has no effect for extension modules & so wouldn't casue issues. Alternatively, could the ctracer extension module be exempted from the deletion?
A