Example of proper handling of threadstate/interplock for low level C thread

Gordon McMillan gmcm at hypernet.com
Tue Mar 28 17:33:20 CEST 2000

Grant Munsey writes:

> I read the API manual on threading and am still a little confused about
> what I have to do to protect the interpreter when a low level C based
> thread gets control of an app and wants to .... say do a
> Py_RunSimpleString().
> Can anyone point me to some source examples that handle threads that
> are not started by the Python interpreter?

There's a few words of explanation at the bottom of the 2nd 
page of


This is really a summary of some long-winded and confusing 
dialogue on the thread SIG from about last June. In practical 
terms, I've only had to dip my toes into this area of Python 
once, and I found something simple that worked for me.

IIRC, there's a CEnterLeavePython (C++) class in Mark 
Hammond's Win32 extensions (source download) that does 
the right thing (may not have the name right).

- Gordon

More information about the Python-list mailing list