Embedding and threads
thomas.heller at ion-tof.com
Thu Nov 4 08:51:00 CET 1999
While embedding python in a DLL I'm writing (we are talking Windows here),
I encountered the following confusion:
Threads are created in the application from C. From reading the docs I
understood that I must 'boot the thread' into existance by creating a thread
state data structure (with PyThreadState_New(), passing the
PyInterpreterState *interp pointer which I saved from the main thread),
then acquire the interpreter lock, and finally store the thread state
pointer before using the Python/C API from this thread.
I do this in the DllMain() function in the DLL_THREAD_ATTACH branch.
This all works very well, but what happens if I also create threads
from python? These threads will be initialized by python, so
I assume the thread state data structure is already created.
How do I ask python if the thread state already exists for a given thread?
More information about the Python-list