- Notifications
You must be signed in to change notification settings - Fork749
Remove suggestions to useinternal
functions#2092
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
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -42,28 +42,39 @@ application. | ||
Before interacting with any of the objects or APIs provided by the | ||
``Python.Runtime`` namespace, calling code must have acquired the Python | ||
Comment on lines -50 to -52 Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. IMHO, "when finished" section needs corresponding replacement (maybe merged with the acquisition part). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Better? | ||
global interpreter lock by ``using'' ``Py.GIL()``. The only exception to | ||
this rule is the ``PythonEngine.Initialize`` method, which may be called | ||
at startup without having acquired the GIL. The GIL is released again | ||
by disposing the return value of `Py.GIL()`: | ||
.. code:: csharp | ||
using (Py.GIL()) | ||
{ | ||
PythonEngine.Exec("doStuff()"); | ||
} | ||
// or | ||
{ | ||
using var _ = Py.GIL() | ||
PythonEngine.Exec("doStuff()"); | ||
} | ||
// or | ||
var gil = Py.GIL(); | ||
try | ||
{ | ||
PythonEngine.Exec("doStuff()"); | ||
} | ||
finally | ||
{ | ||
gil.Dispose(); | ||
} | ||
The``Py.GIL()'' object is athinwrapper over the unmanaged | ||
``PyGILState_Ensure``(on construction)and ``PyGILState_Release``(on | ||
disposal) functionsfrom the Python API, and the documentation for those | ||
APIs applies to themanaged versions. | ||
Passing C# Objects to the Python Engine | ||
--------------------------------------- | ||