[Python-checkins] python/dist/src/Doc/api init.tex,1.21,1.21.2.1
fdrake at users.sourceforge.net
fdrake at users.sourceforge.net
Wed Jan 19 05:13:17 CET 2005
Update of /cvsroot/python/python/dist/src/Doc/api
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32229/api
Modified Files:
Tag: release24-maint
init.tex
Log Message:
Clean up discussion of new C thread idiom
(closes SF patch #1031233; modified)
Index: init.tex
===================================================================
RCS file: /cvsroot/python/python/dist/src/Doc/api/init.tex,v
retrieving revision 1.21
retrieving revision 1.21.2.1
diff -u -d -r1.21 -r1.21.2.1
--- init.tex 11 Oct 2004 02:40:35 -0000 1.21
+++ init.tex 19 Jan 2005 04:13:14 -0000 1.21.2.1
@@ -455,19 +455,10 @@
pointer, release the lock, and finally free their thread state data
structure.
-When creating a thread data structure, you need to provide an
-interpreter state data structure. The interpreter state data
-structure holds global data that is shared by all threads in an
-interpreter, for example the module administration
-(\code{sys.modules}). Depending on your needs, you can either create
-a new interpreter state data structure, or share the interpreter state
-data structure used by the Python main thread (to access the latter,
-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
+Beginning with version 2.3, threads can now take advantage of the
+\cfunction{PyGILState_*()} functions to do all of the above
+automatically. The typical idiom for calling into Python from a C
+thread is now:
\begin{verbatim}
PyGILState_STATE gstate;
@@ -481,6 +472,13 @@
PyGILState_Release(gstate);
\end{verbatim}
+Note that the \cfunction{PyGILState_*()} functions assume there is only
+one global interpreter (created automatically by
+\cfunction{Py_Initialize()}). Python still supports the creation of
+additional interpreters (using \cfunction{Py_NewInterpreter()}), but
+mixing multiple interpreters and the \cfunction{PyGILState_*()} API is
+unsupported.
+
\begin{ctypedesc}{PyInterpreterState}
This data structure represents the state shared by a number of
cooperating threads. Threads belonging to the same interpreter
More information about the Python-checkins
mailing list