Releasing GIL in long-running C# method causes "Fatal Python error: PyEval_SaveThread: the function must be called with the GIL held, but the GIL is released (the current Python thread state is NULL)" #2209
sherryyshi
started this conversation in
General
Replies: 2 comments 3 replies
|
When Python calls C# GIL is not held in the first place, so no need to release anything. |
1 reply
|
Hi @lostmsu. I'm confused by your comment:
This seems to contradict this page https://github.com/pythonnet/pythonnet/wiki/Threading which says: "If you are calling C# from Python, and the C# code performs a long-running operation (e.g. computation, I/O, sleep, acquiring a lock, ...), release the GIL via PythonEngine.BeginAllowThreads(). Remember to restore it before returning control to Python" The same question is here: #2424 |
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Environment
Details
I'm trying to prevent a long running method in C# from blocking execution in Python. I followed the guidance on https://github.com/pythonnet/pythonnet/wiki/Threading but I am getting a crash.
Minimal, Complete, and Verifiable example
this will help us understand the issue.
All reactions