Explain Python extensions multithreading
- by Checkers
Python interpreter has a Global Interpreter Lock, and it is my understanding that extensions must acquire it in a multi-threaded environment. But Boost.Python HOWTO page says the extension function must release the GIL and reacquire it on exit.
I want to resist temptation to guess here, so I would like to know what should be GIL locking patterns in the following scenarios:
Extension is called from python (presumably running in a python thread).
And extension's background thread calls back into Py_* functions.
And a final question is, why the linked document says the GIL should be released and re-acquired?