I am starting threads in a C extension. If I understand correctly, successive sequences of PyGILState_Ensure() and PyGILState_Release will create and destroy the Python thread state over and over again, so e.g. objects stored with threading.Local() will not persist.
Can someone explain to me how I can initialize and destroy the thread state manually (i.e., right after creating and destroying the thread with pthreads), so that PyGILState_* will just acquire and release the GIL?
I guess I have to call PyThreadState_New(), but I am not sure what to do with the returned pointer and where to get the PyInterpreter argument from...
-- »Time flies like an arrow, fruit flies like a Banana.«
PGP fingerprint: 5B93 61F8 4EA2 E279 ABF6 02CF A9AD B7F8 AE4E 425C