Handle ProcessExit event by lostmsu · Pull Request #1458 · pythonnet/pythonnet
This avoids segfault when CLR (in particular Mono) is unloaded before Python stops.
What does this implement/fix? Explain your changes.
- Added a handler to
AppDomain.ProcessExit, that fires in the situations like this instead ofAppDomain.DomainUnload. This allows Python.NET to remove all slots, that are implemented in C#. - When initialized as extension (e.g. Python hosts CLR), release GIL acquired during shutdown so that Python finalization can resume.
Does this close any currently open issues?
This is (at least one of) the reason of CI test crashes in #1134