[Python-Dev] Extension modules, Threading, and the GIL
"Martin v. Löwis"
martin@v.loewis.de
Wed, 08 Jan 2003 14:26:13 +0100
Mark Hammond wrote:
> 1) Allow "arbitrary" threads (that is, threads never before seen by Python)
> to acquire the resources necessary to call the Python C API.
This is possible today, all you need is a pointer to an interpreter
state. If you have that, you can use PyThreadState_New,
PyEval_AcquireThread, after which you have the resources necessary to
call the Python API.
In many cases, extensions can safely assume that there is exactly one
interpreter state all the time, so they can safe the interpreter pointer
in their init function.
Regards,
Martin