8000 PythonEngine.Shutdown() Crash · Issue #2107 · pythonnet/pythonnet · GitHub
[go: up one dir, main page]

Skip to content

PythonEngine.Shutdown() Crash #2107

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
nlogozzo opened this issue Feb 20, 2023 · 5 comments
Closed

PythonEngine.Shutdown() Crash #2107

nlogozzo opened this issue Feb 20, 2023 · 5 comments
Labels
Milestone

Comments

@nlogozzo
Copy link

Environment

  • Pythonnet version: 3.0.1
  • Python version: 3.7.3
  • Operating System: Windows 11 (Same happens when running on WSL - Ubuntu)
  • .NET Runtime: .NET 7

Details

Calling Python.Runtime.PythonEngine.Shutdown(); results in the error:

System.NotSupportedException: 'BinaryFormatter serialization and deserialization are disabled within this application. See https://aka.ms/binaryformatter for more information.'
@nlogozzo nlogozzo changed the title PythonEngine.Shutdown() Error PythonEngine.Shutdown() Crash Feb 20, 2023
@filmor filmor added the bug label Feb 23, 2023
@filmor filmor added this to the 3.0.2 milestone Feb 23, 2023
@filmor
Copy link
Member
filmor commented Feb 23, 2023

Workaround here: #2008 (comment)

@lostmsu
Copy link
Member
lostmsu commented May 3, 2023

@filmor do we even need Shutdown on .NET Core?

@filmor filmor modified the milestones: 3.0.2, 3.0.3 Aug 29, 2023
@filmor
Copy link
Member
filmor commented Sep 23, 2023

We need to call Shutdown (in my opinion) just as well to ensure that destructors run in a sensible order. What we definitely don't need to do is the stashing part. It only needs to run if we want to reload domains, which is not supported on .NET Core anyway. I'm currently working on this (and related slowness during shutdowns) here:

#2245

@JKingas
Copy link
JKingas commented Jun 4, 2024

I recently tried pythonnet in C# Console Application in Visual Studio 2022.

Environment

  • Pythonnet version: 3.0.3
  • Python version: 3.12.3
  • Operating System: Windows 11 23H2
  • .NET Runtime: .NET 8

For now, Shutdown is needed, because without it, one of the threads does not allow the process to end completely.
Then I tried to call Shutdown but got this exception in the PR.

In this case, need to add <EnableUnsafeBinaryFormatterSerialization>true</EnableUnsafeBinaryFormatterSerialization> to the project file. Even with this flag, the process does not terminate without Shutdown.

And after this flag and call Shutdown the process ends correctly.

@filmor
Copy link
Member
filmor commented Sep 19, 2024

This should be fixed now.

@filmor filmor closed this as completed Sep 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants
0