Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
8e3cc1f1
Commit
8e3cc1f1
authored
Mar 02, 2003
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit MvL's doc patch for SF bug #221327. This adds an example of
calling into Python from a C thread.
parent
0cf5996a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
0 deletions
+22
-0
Doc/api/init.tex
Doc/api/init.tex
+22
-0
No files found.
Doc/api/init.tex
View file @
8e3cc1f1
...
...
@@ -466,6 +466,28 @@ you must obtain the thread state and access its \member{interp} member;
this must be done by a thread that is created by Python or by the main
thread after Python is initialized).
Assuming you have access to an interpreter object, the typical idiom
for calling into Python from a C thread is
\begin{verbatim}
PyThreadState *tstate;
PyObject *result;
/* interp is your reference to an interpreter object. */
tstate = PyThreadState
_
New(interp);
PyEval
_
AcquireThread(tstate);
/* Perform Python actions here. */
result = CallSomeFunction();
/* evaluate result */
/* Release the thread. No Python API allowed beyond this point. */
PyEval
_
ReleaseThread(tstate);
/* You can either delete the thread state, or save it
until you need it the next time. */
PyThreadState
_
Delete(tstate);
\end{verbatim}
\begin{ctypedesc}
{
PyInterpreterState
}
This data structure represents the state shared by a number of
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment