On Tuesday, May 31, 2016 at 10:14:31 PM UTC+12, qsh...@alumni.sjtu.edu.cn wrote: > PyGILState_Ensure/PyGILState_Release. Without a running sample, it is a > little bit hard to understand how Python thread and the native pthread > interact.
Python threads *are* native threads (at least on Linux). The place to release the GIL is where you are a) not making any Python API calls and b) doing something CPU-intensive. Point a) is essential. Here <https://github.com/ldo/grainypy/blob/master/grainyx.c> is one of my example extension modules. It doesn’t actually do any multithreading, but I put in the Py_{BEGIN,END}_ALLOW_THREADS calls where I thought it made sense to have them anyway. -- https://mail.python.org/mailman/listinfo/python-list