Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Handle ProcessExit event#1458

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
lostmsu merged 1 commit intopythonnet:masterfromlosttech:bugs/PyCrashOnExit
May 29, 2021

Conversation

lostmsu
Copy link
Member

This avoids segfault when CLR (in particular Mono) is unloaded before Python stops.

What does this implement/fix? Explain your changes.

  1. Added a handler toAppDomain.ProcessExit, that fires in the situations like this instead ofAppDomain.DomainUnload. This allows Python.NET to remove all slots, that are implemented in C#.
  2. 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

@@ -393,6 +393,10 @@ internal static void Shutdown(ShutdownMode mode)
{
Py_Finalize();
}
else
{
PyGILState_Release(state);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

This change seems unrelated, why did you add this?

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Without thisPy_Finalize called when Python finally shuts down hangs because it can't acquire GIL.

@lostmsu
Copy link
MemberAuthor

I debugged the test failures, and they appear to be caused by gaps in domain reload support: when .NET objects that Python sees get severed from CLR, subsequent calls to theirtp_dealloc fail becauseGetManagedObject returnsnull.

@lostmsu
Copy link
MemberAuthor

Found a way to solve the same problem and more without handlingProcessExit

@lostmsu
Copy link
MemberAuthor

Or maybe not. Seems to still be essential for#1134

@lostmsulostmsu reopened thisMay 29, 2021
@lostmsulostmsu requested a review fromfilmorMay 29, 2021 23:10
@lostmsulostmsu merged commit7eac886 intopythonnet:masterMay 29, 2021
@lostmsulostmsu deleted the bugs/PyCrashOnExit branchMay 29, 2021 23:43
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@filmorfilmorAwaiting requested review from filmor

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@lostmsu@filmor

[8]ページ先頭

©2009-2025 Movatter.jp