[Python-Dev] thread issues when embedding Python

Chris Angelico rosuav at gmail.com
Wed Dec 18 16:02:23 CET 2013


On Wed, Dec 18, 2013 at 9:26 PM, Daniel Pocock <daniel at pocock.com.au> wrote:
> b) when each worker thread starts, call
> PyThreadState_New(mInterpreterState)  and save the result in a thread
> local mPyThreadState
>
> c) use the mPyThreadState with PyEval_RestoreThread and
> PyEval_SaveThread before and after calling Python methods
>
> Is this a bug in PyGILState_Ensure or is it a deficiency in the
> documentation?

It doesn't surprise me that you would need to do step b - I do seem to
recall the need to call that for each new thread. Not so sure about c.
Once you fixed the unrelated bug, do you still need that step? (Been a
while since I last embedded Python though, and I might well be wrong.)

ChrisA


More information about the Python-Dev mailing list